-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #366 from cexbrayat/test/typescript-without-babel
test: add typescript e2e test without babel
- Loading branch information
Showing
9 changed files
with
147 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "vue3-typescript-with-babel", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"private": true, | ||
"scripts": { | ||
"test": "jest --no-cache ./sub-project/test.js" | ||
}, | ||
"dependencies": { | ||
"@vue/compiler-sfc": "^3.0.3", | ||
"vue": "^3.0.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.9.0", | ||
"@babel/preset-env": "^7.9.0", | ||
"jest": "^26.0.0", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.2", | ||
"vue3-jest": "^26.0.0-alpha.10" | ||
}, | ||
"jest": { | ||
"testEnvironment": "jsdom", | ||
"globals": { | ||
"vue-jest": { | ||
"tsConfig": "./sub-project/tsconfig.json" | ||
} | ||
}, | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"vue" | ||
], | ||
"transform": { | ||
"^.+\\.js$": "babel-jest", | ||
"^.+\\.vue$": "vue3-jest" | ||
} | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"@babel/env" | ||
] | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<template> | ||
<div class="hello"> | ||
<h1 :class="headingClasses">{{ msg }}</h1> | ||
</div> | ||
</template> | ||
|
||
<style module="css"> | ||
.testA { | ||
background-color: red; | ||
} | ||
</style> | ||
<style module> | ||
.testB { | ||
background-color: blue; | ||
} | ||
</style> | ||
<style> | ||
.testC { | ||
background-color: blue; | ||
} | ||
</style> | ||
|
||
<script lang="ts"> | ||
import { computed, defineComponent, ref } from 'vue' | ||
export default defineComponent({ | ||
name: 'basic', | ||
setup() { | ||
const msg = 'Welcome to Your Vue.js App' | ||
const isCrazy = ref(false) | ||
const headingClasses = computed(() => ({ | ||
red: isCrazy, | ||
blue: !isCrazy, | ||
shadow: isCrazy | ||
})) | ||
const toggleClass = () => (isCrazy.value = !isCrazy.value) | ||
return { | ||
msg, | ||
isCrazy, | ||
headingClasses, | ||
toggleClass | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module '*.vue' { | ||
import type { DefineComponent } from 'vue'; | ||
const component: DefineComponent<{}, {}, any>; | ||
export default component; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { createApp, h } from 'vue' | ||
|
||
import Basic from '@/components/Basic.vue' | ||
|
||
function mount(Component: any) { | ||
document.getElementsByTagName('html')[0].innerHTML = '' | ||
const el = document.createElement('div') | ||
el.id = 'app' | ||
document.body.appendChild(el) | ||
const Parent = { | ||
render() { | ||
return h(Component) | ||
} | ||
} | ||
createApp(Parent).mount(el) | ||
} | ||
|
||
test('processes .vue files', () => { | ||
mount(Basic) | ||
expect(document.querySelector('h1')!.textContent).toBe( | ||
'Welcome to Your Vue.js App' | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "esnext", | ||
"strict": true, | ||
"jsx": "preserve", | ||
"importHelpers": true, | ||
"moduleResolution": "node", | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"useDefineForClassFields": true, | ||
"sourceMap": true, | ||
"baseUrl": ".", | ||
"types": ["webpack-env", "jest"], | ||
"paths": { | ||
"@/*": ["src/*"] | ||
}, | ||
"lib": ["esnext", "dom", "dom.iterable", "scripthost"] | ||
}, | ||
"include": ["src/**/*.ts", "src/**/*.vue"], | ||
"exclude": ["node_modules"] | ||
} |