Skip to content

Commit 3efc733

Browse files
committed
Fix jest tests
1 parent e5e27c6 commit 3efc733

File tree

6 files changed

+81
-14
lines changed

6 files changed

+81
-14
lines changed

package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
"winston": "^2.3.1"
3939
},
4040
"devDependencies": {
41+
"@types/jest": "^20.0.1",
4142
"@types/lodash": "^4.14.66",
4243
"@types/lodash.defaults": "^4.2.2",
4344
"@types/lodash.omit": "^4.5.2",
4445
"@types/node": "^6.0.34",
4546
"@types/traverse": "^0.6.29",
47+
"@types/which": "^1.0.28",
4648
"@types/winston": "^2.3.3",
4749
"babel-core": "^6.25.0",
4850
"eslint": "^3.19.0",
@@ -55,7 +57,7 @@
5557
"nodemon": "^1.3.7",
5658
"prettier": "^1.4.2",
5759
"typescript": "^2.0.0",
58-
"which": "^1.1.1"
60+
"which": "^1.2.14"
5961
},
6062
"scripts": {
6163
"test": "jest --runInBand",
@@ -73,9 +75,22 @@
7375
]
7476
},
7577
"jest": {
78+
"moduleFileExtensions": [
79+
"ts",
80+
"tsx",
81+
"js"
82+
],
83+
"transform": {
84+
"^.+\\.(ts|tsx)$": "<rootDir>/preprocessor.js"
85+
},
86+
"testMatch": [
87+
"**/__tests__/**/*.(j|t)s?(x)",
88+
"**/?(*.)(spec|test).(t|j)s?(x)"
89+
],
7690
"coverageDirectory": "./coverage/",
7791
"testPathIgnorePatterns": [
7892
"node_modules",
93+
"lib",
7994
"scripts",
8095
"__tests__/integration/rplugin"
8196
]

preprocessor.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2004-present Facebook. All Rights Reserved.
2+
3+
const tsc = require('typescript');
4+
const tsConfig = require('./tsconfig.json');
5+
6+
module.exports = {
7+
process(src, path) {
8+
if (path.endsWith('.ts') || path.endsWith('.tsx')) {
9+
return tsc.transpile(src, tsConfig.compilerOptions, path, []);
10+
}
11+
return src;
12+
},
13+
};

src/api/Tabpage.test.js renamed to src/api/Tabpage.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-env jest */
2-
const cp = require('child_process');
3-
// eslint-disable-next-line import/no-extraneous-dependencies
4-
const which = require('which');
5-
const attach = require('../attach');
2+
import * as child_process from 'child_process';
3+
// // eslint-disable-next-line import/no-extraneous-dependencies
4+
import * as which from 'which';
5+
import { attach } from '../attach';
66

77
try {
88
which.sync('nvim');
@@ -20,7 +20,7 @@ describe('Tabpage API', () => {
2020
let nvim;
2121

2222
beforeAll(async done => {
23-
proc = cp.spawn(
23+
proc = child_process.spawn(
2424
'nvim',
2525
['-u', 'NONE', '-N', '--embed', '-c', 'set noswapfile', 'test.js'],
2626
{

src/attach/attach.test.js renamed to src/attach/attach.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-env jest */
2-
const cp = require('child_process');
3-
// eslint-disable-next-line import/no-extraneous-dependencies
4-
const which = require('which');
5-
const attach = require('./attach');
2+
import * as cp from 'child_process';
3+
// // eslint-disable-next-line import/no-extraneous-dependencies
4+
import * as which from 'which';
5+
import { attach } from './attach';
66

77
try {
88
which.sync('nvim');
@@ -22,6 +22,7 @@ describe('Nvim Promise API', () => {
2222
let notifications;
2323

2424
beforeAll(async done => {
25+
try {
2526
proc = cp.spawn(
2627
'nvim',
2728
['-u', 'NONE', '-N', '--embed', '-c', 'set noswapfile'],
@@ -30,6 +31,7 @@ describe('Nvim Promise API', () => {
3031
}
3132
);
3233

34+
3335
nvim = await attach({ proc });
3436
nvim.on('request', (method, args, resp) => {
3537
requests.push({ method, args });
@@ -40,6 +42,7 @@ describe('Nvim Promise API', () => {
4042
});
4143

4244
done();
45+
} catch (err) { console.log(err); }
4346
});
4447

4548
afterAll(() => {

tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"src/**/*.ts"
1919
],
2020
"exclude": [
21-
"node_modules"
21+
"node_modules",
22+
"examples",
23+
"lib"
2224
]
23-
}
25+
}

yarn.lock

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,44 @@
22
# yarn lockfile v1
33

44

5-
"@types/node@^6.0.34":
5+
"@types/jest@^20.0.1":
6+
version "20.0.1"
7+
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-20.0.1.tgz#8643a195d925a00f7bdee5257d12c3aac743f3b4"
8+
9+
"@types/lodash.defaults@^4.2.2":
10+
version "4.2.2"
11+
resolved "https://registry.yarnpkg.com/@types/lodash.defaults/-/lodash.defaults-4.2.2.tgz#16a173eb7905ca2f3ad5306fae7fcf62ff166ee2"
12+
dependencies:
13+
"@types/lodash" "*"
14+
15+
"@types/lodash.omit@^4.5.2":
16+
version "4.5.2"
17+
resolved "https://registry.yarnpkg.com/@types/lodash.omit/-/lodash.omit-4.5.2.tgz#f2dde22e380908e13447265f42df59b74b8eb73a"
18+
dependencies:
19+
"@types/lodash" "*"
20+
21+
"@types/lodash@*", "@types/lodash@^4.14.66":
22+
version "4.14.66"
23+
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.66.tgz#3dbb83477becf130611f8fac82a8fdb199805981"
24+
25+
"@types/node@*", "@types/node@^6.0.34":
626
version "6.0.78"
727
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.78.tgz#5d4a3f579c1524e01ee21bf474e6fba09198f470"
828

29+
"@types/traverse@^0.6.29":
30+
version "0.6.29"
31+
resolved "https://registry.yarnpkg.com/@types/traverse/-/traverse-0.6.29.tgz#2e9d1f18bfb009ab26e1cbb130376d1fc2726341"
32+
33+
"@types/which@^1.0.28":
34+
version "1.0.28"
35+
resolved "https://registry.yarnpkg.com/@types/which/-/which-1.0.28.tgz#016e387629b8817bed653fe32eab5d11279c8df6"
36+
37+
"@types/winston@^2.3.3":
38+
version "2.3.3"
39+
resolved "https://registry.yarnpkg.com/@types/winston/-/winston-2.3.3.tgz#f3eeea27c02f08aaeb60e535804b235f8378eff4"
40+
dependencies:
41+
"@types/node" "*"
42+
943
abab@^1.0.3:
1044
version "1.0.3"
1145
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d"
@@ -3352,7 +3386,7 @@ which-module@^1.0.0:
33523386
version "1.0.0"
33533387
resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f"
33543388

3355-
which@^1.1.1, which@^1.2.10, which@^1.2.12, which@^1.2.9:
3389+
which@^1.2.10, which@^1.2.12, which@^1.2.14, which@^1.2.9:
33563390
version "1.2.14"
33573391
resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"
33583392
dependencies:

0 commit comments

Comments
 (0)