Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2853d7

Browse filesBrowse files
authored
feat: add support for specific tsconfig file path inside of vue-jest jest.config.js options (#324)
* feat: add support for specific tsconfig file path inside of vue-jest jest.config.js options (#309) * chore: modify package name property * style: avoid use Optional Chaining
1 parent 9c4eef1 commit e2853d7
Copy full SHA for e2853d7

File tree

Expand file treeCollapse file tree

5 files changed

+135
-1
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+135
-1
lines changed
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "typescript",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"private": true,
7+
"scripts": {
8+
"test": "jest --no-cache ./sub-project/test.js"
9+
},
10+
"dependencies": {
11+
"vue": "3.0.0-alpha.10"
12+
},
13+
"devDependencies": {
14+
"@babel/core": "^7.2.2",
15+
"@babel/preset-env": "^7.2.3",
16+
"jest": "^24.0.0"
17+
},
18+
"jest": {
19+
"globals": {
20+
"vue-jest": {
21+
"tsConfig": "./sub-project/tsconfig.json"
22+
}
23+
},
24+
"moduleFileExtensions": [
25+
"js",
26+
"json",
27+
"vue"
28+
],
29+
"transform": {
30+
"^.+\\.js$": "babel-jest",
31+
"^.+\\.vue$": "../../../lib/index.js"
32+
}
33+
},
34+
"babel": {
35+
"presets": [
36+
"@babel/env"
37+
]
38+
}
39+
}
+48Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<div class="hello">
3+
<h1 :class="headingClasses">{{ msg }}</h1>
4+
</div>
5+
</template>
6+
7+
<style module="css">
8+
.testA {
9+
background-color: red;
10+
}
11+
</style>
12+
<style module>
13+
.testB {
14+
background-color: blue;
15+
}
16+
</style>
17+
<style>
18+
.testC {
19+
background-color: blue;
20+
}
21+
</style>
22+
23+
<script lang="ts">
24+
export default {
25+
name: 'basic',
26+
computed: {
27+
headingClasses: function headingClasses() {
28+
return {
29+
red: this.isCrazy,
30+
blue: !this.isCrazy,
31+
shadow: this.isCrazy
32+
}
33+
}
34+
},
35+
data: function data() {
36+
const msg: string = 'Welcome to Your Vue.js App'
37+
return {
38+
msg,
39+
isCrazy: false
40+
}
41+
},
42+
methods: {
43+
toggleClass: function toggleClass() {
44+
this.isCrazy = !this.isCrazy
45+
}
46+
}
47+
}
48+
</script>
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { createApp, h } from 'vue'
2+
3+
import Basic from './components/Basic.vue'
4+
5+
function mount(Component, props, slots) {
6+
document.getElementsByTagName('html')[0].innerHTML = ''
7+
const el = document.createElement('div')
8+
el.id = 'app'
9+
document.body.appendChild(el)
10+
const Parent = {
11+
render() {
12+
return h(Component, props, slots)
13+
}
14+
}
15+
createApp(Parent).mount(el)
16+
}
17+
18+
test('processes .vue files', () => {
19+
mount(Basic)
20+
expect(document.querySelector('h1').textContent).toBe(
21+
'Welcome to Your Vue.js App'
22+
)
23+
})
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["dom", "es6"],
5+
"module": "es2015",
6+
"moduleResolution": "node",
7+
"types": ["vue-typescript-import-dts", "node"],
8+
"isolatedModules": false,
9+
"experimentalDecorators": true,
10+
"noImplicitAny": true,
11+
"noImplicitThis": true,
12+
"strictNullChecks": true,
13+
"removeComments": true,
14+
"emitDecoratorMetadata": true,
15+
"suppressImplicitAnyIndexErrors": true,
16+
"allowSyntheticDefaultImports": true,
17+
"sourceMap": true,
18+
"allowJs": true
19+
}
20+
}

‎lib/utils.js

Copy file name to clipboardExpand all lines: lib/utils.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ const getBabelOptions = function loadBabelOptions(filename, options = {}) {
6565
}
6666

6767
const getTsJestConfig = function getTsJestConfig(config) {
68-
const isUsingTs = resolveTsConfigSync(process.cwd())
68+
const tsConfigPath = path.resolve(
69+
process.cwd(),
70+
getVueJestConfig(config).tsConfig || ''
71+
)
72+
const isUsingTs = resolveTsConfigSync(tsConfigPath)
6973
if (!isUsingTs) {
7074
return null
7175
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.