Skip to content

Commit 932c9bc

Browse files
author
Adam Hines
committed
test(vue3): adding e2e tests for sass-importer
1 parent c5d1a69 commit 932c9bc

File tree

11 files changed

+155
-1
lines changed

11 files changed

+155
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const { createTransformer } = require('babel-jest').default
2+
module.exports = createTransformer({
3+
presets: ['@babel/preset-env']
4+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<div>
3+
<h1 class="entry">Entry</h1>
4+
<lib-component />
5+
</div>
6+
</template>
7+
8+
<script>
9+
import LibComponent from 'vue3-sass-importer-lib/index.vue'
10+
11+
export default {
12+
components: {
13+
LibComponent
14+
}
15+
}
16+
</script>
17+
18+
<style lang="scss" module>
19+
@import '~vue3-sass-importer-sass-lib/index.scss';
20+
21+
.entry {
22+
@include my-v2-mixin;
23+
}
24+
</style>
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "vue3-sass-importer-entry",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"private": true,
6+
"scripts": {
7+
"test": "jest --no-cache --coverage test.js"
8+
},
9+
"dependencies": {
10+
"vue": "^3.2.22",
11+
"vue3-sass-importer-lib": "file:../lib",
12+
"vue3-sass-importer-sass-lib": "file:../sass-lib-v2"
13+
},
14+
"devDependencies": {
15+
"@babel/core": "^7.9.0",
16+
"@babel/preset-env": "^7.9.0",
17+
"@vue/test-utils": "^1.1.0",
18+
"babel-jest": "^28.0.2",
19+
"jest": "28.x",
20+
"jest-environment-jsdom": "28.0.2",
21+
"postcss": "^7.0.13",
22+
"postcss-color-function": "^4.0.1",
23+
"sass": "^1.23.7",
24+
"@vue/vue3-jest": "^28.0.0"
25+
},
26+
"jest": {
27+
"testEnvironment": "jsdom",
28+
"moduleFileExtensions": [
29+
"js",
30+
"json",
31+
"vue"
32+
],
33+
"transformIgnorePatterns": [
34+
"/node_modules/.*(?<!.vue)$"
35+
],
36+
"transform": {
37+
"^.+\\.js$": "./babel-transformer.js",
38+
"^.+\\.vue$": "@vue/vue3-jest"
39+
},
40+
"globals": {
41+
"vue-jest": {
42+
"transform": {
43+
"^js$": "./babel-transformer.js"
44+
}
45+
}
46+
}
47+
}
48+
}

e2e/3.x/sass-importer/entry/test.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { mount } from '@vue/test-utils'
2+
import Entry from './components/Entry.vue'
3+
4+
test('processes sass imports relative to current file', () => {
5+
const wrapper = mount(Entry)
6+
expect(wrapper).toBeDefined()
7+
})

e2e/3.x/sass-importer/lib/index.vue

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<div class="lib-class">Lib Component</div>
3+
</template>
4+
5+
<style lang="scss" module>
6+
@import '~vue3-sass-importer-sass-lib/index.scss';
7+
8+
.lib-class {
9+
@include my-v1-mixin;
10+
}
11+
</style>
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "vue3-sass-importer-lib",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"private": true,
6+
"main": "index.vue",
7+
"files": [
8+
"index.vue"
9+
],
10+
"scripts": {
11+
"test": "echo 'No tests found.'"
12+
},
13+
"dependencies": {
14+
"vue3-sass-importer-sass-lib": "file:../sass-lib-v1"
15+
},
16+
"peerDependencies": {
17+
"vue": "^3.2.22"
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@mixin my-v1-mixin {
2+
color: blue;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "vue3-sass-importer-sass-lib",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"private": true,
6+
"files": [
7+
"index.scss"
8+
],
9+
"scripts": {
10+
"test": "echo 'No tests found.'"
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@mixin my-v2-mixin {
2+
color: red;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "vue3-sass-importer-sass-lib",
3+
"version": "2.0.0",
4+
"license": "MIT",
5+
"private": true,
6+
"files": [
7+
"index.scss"
8+
],
9+
"scripts": {
10+
"test": "echo 'No tests found.'"
11+
}
12+
}

yarn.lock

+12-1
Original file line numberDiff line numberDiff line change
@@ -10868,14 +10868,25 @@ vue-template-es2015-compiler@^1.9.0:
1086810868
"vue2-sass-importer-lib@file:e2e/2.x/sass-importer/lib":
1086910869
version "1.0.0"
1087010870
dependencies:
10871-
vue2-sass-importer-sass-lib "file:../../.cache/yarn/v6/npm-vue2-sass-importer-lib-1.0.0-c953c300-a005-492f-9652-a1024a3a28b9-1656106782763/node_modules/sass-lib-v1"
10871+
vue2-sass-importer-sass-lib "file:../../.cache/yarn/v6/npm-vue2-sass-importer-lib-1.0.0-1087f856-8699-4ac6-a0fa-2288988256c2-1656107462461/node_modules/sass-lib-v1"
1087210872

1087310873
"vue2-sass-importer-sass-lib@file:e2e/2.x/sass-importer/sass-lib-v1":
1087410874
version "1.0.0"
1087510875

1087610876
"vue2-sass-importer-sass-lib@file:e2e/2.x/sass-importer/sass-lib-v2":
1087710877
version "2.0.0"
1087810878

10879+
"vue3-sass-importer-lib@file:e2e/3.x/sass-importer/lib":
10880+
version "1.0.0"
10881+
dependencies:
10882+
vue3-sass-importer-sass-lib "file:../../.cache/yarn/v6/npm-vue3-sass-importer-lib-1.0.0-c866bb73-f527-47b9-932d-498dea4cf3d0-1656107462461/node_modules/sass-lib-v1"
10883+
10884+
"vue3-sass-importer-sass-lib@file:e2e/3.x/sass-importer/sass-lib-v1":
10885+
version "1.0.0"
10886+
10887+
"vue3-sass-importer-sass-lib@file:e2e/3.x/sass-importer/sass-lib-v2":
10888+
version "2.0.0"
10889+
1087910890
vue@^2.4.2, vue@^2.5.21:
1088010891
version "2.6.14"
1088110892
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.14.tgz#e51aa5250250d569a3fbad3a8a5a687d6036e235"

0 commit comments

Comments
 (0)