Skip to content

Commit f61b737

Browse files
SasanFarrokhSasan Farrokh
andauthored
test: compilerOptions (#385)
test(compilerOptions): ensure compilerOptions is passed down Co-authored-by: Sasan Farrokh <[email protected]>
1 parent 05fc5ee commit f61b737

File tree

5 files changed

+45
-25
lines changed

5 files changed

+45
-25
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div>
3+
<h1 class="header" v-test="'value'">Hello</h1>
4+
</div>
5+
</template>

e2e/3.x/basic/jest.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const vTestDirective = require('./v-test-directive')
2+
3+
module.exports = {
4+
testEnvironment: 'jsdom',
5+
moduleFileExtensions: ['js', 'json', 'vue', 'ts'],
6+
transform: {
7+
'^.+\\.ts$': 'ts-jest',
8+
'^.+\\.js$': 'babel-jest',
9+
'^.+\\.vue$': '@vue/vue3-jest'
10+
},
11+
moduleNameMapper: {
12+
'^~?__styles/(.*)$': '<rootDir>/components/styles/$1'
13+
},
14+
globals: {
15+
'vue-jest': {
16+
pug: {
17+
basedir: './'
18+
},
19+
compilerOptions: {
20+
directiveTransforms: {
21+
test: vTestDirective
22+
}
23+
}
24+
}
25+
}
26+
}

e2e/3.x/basic/package.json

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,5 @@
2525
"vue-class-component": "^8.0.0-beta.4",
2626
"@vue/vue3-jest": "^27.0.0-alpha.1",
2727
"vue-property-decorator": "^10.0.0-rc.3"
28-
},
29-
"jest": {
30-
"testEnvironment": "jsdom",
31-
"moduleFileExtensions": [
32-
"js",
33-
"json",
34-
"vue",
35-
"ts"
36-
],
37-
"transform": {
38-
"^.+\\.ts$": "ts-jest",
39-
"^.+\\.js$": "babel-jest",
40-
"^.+\\.vue$": "@vue/vue3-jest"
41-
},
42-
"moduleNameMapper": {
43-
"^~?__styles/(.*)$": "<rootDir>/components/styles/$1"
44-
},
45-
"globals": {
46-
"vue-jest": {
47-
"pug": {
48-
"basedir": "./"
49-
}
50-
}
51-
}
5228
}
5329
}

e2e/3.x/basic/test.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { randomExport } from './components/NamedExport.vue'
2222
import ScriptSetup from './components/ScriptSetup.vue'
2323
import ScriptSetupSugarRef from './components/ScriptSetupSugarRef.vue'
2424
import FunctionalRenderFn from './components/FunctionalRenderFn.vue'
25+
import CompilerDirective from './components/CompilerDirective.vue'
2526

2627
// TODO: JSX for Vue 3? TSX?
2728
import Jsx from './components/Jsx.vue'
@@ -36,7 +37,9 @@ function mount(Component, props, slots) {
3637
return h(Component, props, slots)
3738
}
3839
}
39-
createApp(Parent).mount(el)
40+
const app = createApp(Parent)
41+
app.directive('test', el => el.setAttribute('data-test', 'value'))
42+
app.mount(el)
4043
}
4144

4245
test('supports <script setup>', () => {
@@ -197,3 +200,10 @@ test('processes functional component exported as function', () => {
197200
expect(elem).toBeTruthy()
198201
expect(elem.innerHTML).toBe('Nyan')
199202
})
203+
204+
test('ensure compilerOptions is passed down', () => {
205+
mount(CompilerDirective)
206+
207+
const elm = document.querySelector('h1')
208+
expect(elm.hasAttribute('data-test')).toBe(false)
209+
})

e2e/3.x/basic/v-test-directive.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = (dir, node, ...args) => {
2+
return { needRuntime: false, props: [] }
3+
}

0 commit comments

Comments
 (0)