Skip to content

Commit

Permalink
test: compilerOptions (#385)
Browse files Browse the repository at this point in the history
test(compilerOptions): ensure compilerOptions is passed down

Co-authored-by: Sasan Farrokh <[email protected]>
  • Loading branch information
SasanFarrokh and Sasan Farrokh authored Sep 10, 2021
1 parent 05fc5ee commit f61b737
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 25 deletions.
5 changes: 5 additions & 0 deletions e2e/3.x/basic/components/CompilerDirective.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<h1 class="header" v-test="'value'">Hello</h1>
</div>
</template>
26 changes: 26 additions & 0 deletions e2e/3.x/basic/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const vTestDirective = require('./v-test-directive')

module.exports = {
testEnvironment: 'jsdom',
moduleFileExtensions: ['js', 'json', 'vue', 'ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
'^.+\\.js$': 'babel-jest',
'^.+\\.vue$': '@vue/vue3-jest'
},
moduleNameMapper: {
'^~?__styles/(.*)$': '<rootDir>/components/styles/$1'
},
globals: {
'vue-jest': {
pug: {
basedir: './'
},
compilerOptions: {
directiveTransforms: {
test: vTestDirective
}
}
}
}
}
24 changes: 0 additions & 24 deletions e2e/3.x/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,5 @@
"vue-class-component": "^8.0.0-beta.4",
"@vue/vue3-jest": "^27.0.0-alpha.1",
"vue-property-decorator": "^10.0.0-rc.3"
},
"jest": {
"testEnvironment": "jsdom",
"moduleFileExtensions": [
"js",
"json",
"vue",
"ts"
],
"transform": {
"^.+\\.ts$": "ts-jest",
"^.+\\.js$": "babel-jest",
"^.+\\.vue$": "@vue/vue3-jest"
},
"moduleNameMapper": {
"^~?__styles/(.*)$": "<rootDir>/components/styles/$1"
},
"globals": {
"vue-jest": {
"pug": {
"basedir": "./"
}
}
}
}
}
12 changes: 11 additions & 1 deletion e2e/3.x/basic/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { randomExport } from './components/NamedExport.vue'
import ScriptSetup from './components/ScriptSetup.vue'
import ScriptSetupSugarRef from './components/ScriptSetupSugarRef.vue'
import FunctionalRenderFn from './components/FunctionalRenderFn.vue'
import CompilerDirective from './components/CompilerDirective.vue'

// TODO: JSX for Vue 3? TSX?
import Jsx from './components/Jsx.vue'
Expand All @@ -36,7 +37,9 @@ function mount(Component, props, slots) {
return h(Component, props, slots)
}
}
createApp(Parent).mount(el)
const app = createApp(Parent)
app.directive('test', el => el.setAttribute('data-test', 'value'))
app.mount(el)
}

test('supports <script setup>', () => {
Expand Down Expand Up @@ -197,3 +200,10 @@ test('processes functional component exported as function', () => {
expect(elem).toBeTruthy()
expect(elem.innerHTML).toBe('Nyan')
})

test('ensure compilerOptions is passed down', () => {
mount(CompilerDirective)

const elm = document.querySelector('h1')
expect(elm.hasAttribute('data-test')).toBe(false)
})
3 changes: 3 additions & 0 deletions e2e/3.x/basic/v-test-directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (dir, node, ...args) => {
return { needRuntime: false, props: [] }
}

0 comments on commit f61b737

Please sign in to comment.