Skip to content

Commit 59f27f6

Browse files
committedNov 15, 2019
setup jest
·
v0.19.40.2.0
1 parent 66d806b commit 59f27f6

File tree

6 files changed

+237
-74
lines changed

6 files changed

+237
-74
lines changed
 

‎jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
verbose: true,
4+
testPathIgnorePatterns: ['build'],
5+
}

‎package-lock.json

Lines changed: 174 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
"watch": "tsc -watch -p ./"
3131
},
3232
"dependencies": {
33+
"@types/jest": "^24.0.23",
3334
"jsdom": "^15.2.1"
3435
},
3536
"devDependencies": {
3637
"@types/assert": "^1.4.3",
3738
"@types/dotenv": "^8.2.0",
3839
"@types/glob": "^7.1.1",
3940
"@types/jsdom": "^12.2.4",
40-
"@types/mocha": "^5.2.7",
4141
"@types/node": "^12.12.7",
4242
"assert": "^2.0.0",
4343
"concurrently": "^5.0.0",
@@ -46,6 +46,7 @@
4646
"graphql": "^14.5.8",
4747
"mocha": "^6.2.2",
4848
"prettier": "^1.19.1",
49+
"ts-jest": "^24.1.0",
4950
"tslint": "^5.20.1",
5051
"tslint-config-prettier": "^1.18.0",
5152
"typescript": "^3.7.2",

‎src/test/suite/extension.test.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎src/test/suite/extension.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
// // You can import and use all API from the 'vscode' module
3+
// // as well as import your extension to test it
4+
// import * as vscode from 'vscode'
5+
// import {before, after} from 'mocha'
6+
// import * as assert from 'assert'
7+
// // import * as myExtension from '../../extension'
8+
9+
// suite('Extension tests', () => {
10+
// before(() => {
11+
// vscode.window.showInformationMessage('Start all tests.')
12+
// })
13+
14+
// test('Loads App', async () => {
15+
// await vscode.commands.executeCommand('coderoad.start')
16+
// await setTimeout(() => Promise.resolve(), 5000)
17+
// // const webview = vscode.window.activeTextEditor
18+
// assert.equal(2, 2)
19+
// })
20+
21+
// after(() => {
22+
// console.log('done')
23+
// })
24+
// })

‎src/test/suite/index.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
import * as path from 'path'
2-
import * as Mocha from 'mocha'
3-
import * as glob from 'glob'
1+
// import * as path from 'path'
2+
// import * as Mocha from 'mocha'
3+
// import * as glob from 'glob'
44

5-
export function run(): Promise<void> {
6-
// Create the mocha test
7-
const mocha = new Mocha({
8-
ui: 'tdd',
9-
})
10-
mocha.useColors(true)
5+
// export function run(): Promise<void> {
6+
// // Create the mocha test
7+
// const mocha = new Mocha({
8+
// ui: 'tdd',
9+
// })
10+
// mocha.useColors(true)
1111

12-
const testsRoot = path.resolve(__dirname, '..')
12+
// const testsRoot = path.resolve(__dirname, '..')
1313

14-
return new Promise((c, e) => {
15-
glob('**/**.test.js', {cwd: testsRoot}, (err, files) => {
16-
if (err) {
17-
return e(err)
18-
}
14+
// return new Promise((c, e) => {
15+
// glob('**/**.test.js', {cwd: testsRoot}, (err, files) => {
16+
// if (err) {
17+
// return e(err)
18+
// }
1919

20-
// Add files to the test suite
21-
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)))
20+
// // Add files to the test suite
21+
// files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)))
2222

23-
try {
24-
// Run the mocha test
25-
mocha.run(failures => {
26-
if (failures > 0) {
27-
e(new Error(`${failures} tests failed.`))
28-
} else {
29-
c()
30-
}
31-
})
32-
} catch (err) {
33-
e(err)
34-
}
35-
})
36-
})
37-
}
23+
// try {
24+
// // Run the mocha test
25+
// mocha.run(failures => {
26+
// if (failures > 0) {
27+
// e(new Error(`${failures} tests failed.`))
28+
// } else {
29+
// c()
30+
// }
31+
// })
32+
// } catch (err) {
33+
// e(err)
34+
// }
35+
// })
36+
// })
37+
// }

0 commit comments

Comments
 (0)
Please sign in to comment.