Skip to content

Commit a5dbd96

Browse files
committed
feat: update test to support windows
1 parent 2b4899b commit a5dbd96

File tree

7 files changed

+74
-34
lines changed

7 files changed

+74
-34
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ language: node_js
55
node_js:
66
- '10'
77
- '8'
8-
- '6'
98

109
matrix:
1110
fast_finish: true
@@ -25,4 +24,6 @@ before_script:
2524
- git config --global user.name "Sigoden Huang"
2625
- npm run bootstrap
2726

28-
script: npm run test
27+
script:
28+
- npm run lint
29+
- npm test

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"scripts": {
1111
"bootstrap": "lerna bootstrap --hoist",
1212
"lint": "eslint .",
13-
"pretest": "npm run lint",
1413
"test": "jest",
1514
"test:plugins": "node packages/htte-cli/bin/htte.js packages/htte-plugin-builtin/htte/htte.yaml",
1615
"realworld": "node packages/htte-cli/bin/htte.js examples/realworld/htte.yaml"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`reporter @enterGroup 1`] = `
4+
"root
5+
grp1
6+
"
7+
`;
8+
9+
exports[`reporter @runUnit & doneUnit 1`] = `
10+
" √ describe1
11+
"
12+
`;
13+
14+
exports[`reporter @runUnit & doneUnit slow 1`] = `
15+
" √ describe1 (10s)
16+
"
17+
`;
18+
19+
exports[`reporter @runUnit & errorUnit 1`] = `" ◵ describe1"`;
20+
21+
exports[`reporter @runUnit & errorUnit 2`] = `
22+
" 1) describe1
23+
"
24+
`;
25+
26+
exports[`reporter @skipUnit 1`] = `
27+
" * describe1
28+
"
29+
`;
30+
31+
exports[`reporter @start 1`] = `
32+
"
33+
"
34+
`;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`epilogue list statistics 1`] = `
4+
"
5+
3 passed (4s)
6+
2 pending
7+
2 failed
8+
9+
1) module2-> root-> grp2-> describe2
10+
at req*body, throw error: err2
11+
2) module6-> root-> grp6-> describe6
12+
at req*body, throw error: err6
13+
req:
14+
url: /p6
15+
body: req6
16+
res: {}
17+
18+
19+
module5-> root-> grp5-> describe5
20+
req:
21+
url: /p5
22+
body: req5
23+
res:
24+
body: res5
25+
26+
"
27+
`;

packages/htte-reporter-cli/src/__tests__/index.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ describe('reporter', function() {
1919

2020
test('@start', function() {
2121
emitter.emit('start', { units: [], tdd: false });
22-
expect(stdoutWrite.mock.calls.join('')).toBe('\n');
22+
expect(stdoutWrite.mock.calls.join('')).toMatchSnapshot();
2323
});
2424

2525
test('@enterGroup', function() {
2626
let unit = mockUnit(1, 'pass');
2727
emitter.emit('enterGroup', { unit });
28-
expect(stdoutWrite.mock.calls.join('')).toBe(`root\n grp1\n`);
28+
expect(stdoutWrite.mock.calls.join('')).toMatchSnapshot();
2929
});
3030

3131
test('@skipUnit', function() {
3232
let unit = mockUnit(1, 'skip');
3333
emitter.emit('skipUnit', { unit });
34-
expect(stdoutWrite.mock.calls.join('')).toBe(` • describe1\n`);
34+
expect(stdoutWrite.mock.calls.join('')).toMatchSnapshot();
3535
});
3636

3737
test('@runUnit & doneUnit', function(done) {
@@ -40,7 +40,7 @@ describe('reporter', function() {
4040
setTimeout(() => {
4141
expect(stdoutWrite.mock.calls[1][0]).toBe(` ◵ describe1`);
4242
emitter.emit('doneUnit');
43-
expect(stdoutWrite.mock.calls.slice(3).join('')).toBe(` ✔ describe1\n`);
43+
expect(stdoutWrite.mock.calls.slice(3).join('')).toMatchSnapshot();
4444
done();
4545
}, utils.spinnerInterval + 1);
4646
});
@@ -52,7 +52,7 @@ describe('reporter', function() {
5252
setTimeout(() => {
5353
expect(stdoutWrite.mock.calls[1][0]).toBe(` ◵ describe1`);
5454
emitter.emit('doneUnit');
55-
expect(stdoutWrite.mock.calls.slice(3).join('')).toBe(` ✔ describe1 (10s)\n`);
55+
expect(stdoutWrite.mock.calls.slice(3).join('')).toMatchSnapshot();
5656
done();
5757
}, utils.spinnerInterval + 1);
5858
});
@@ -61,9 +61,9 @@ describe('reporter', function() {
6161
let unit = mockUnit(1, 'fail');
6262
emitter.emit('runUnit', { unit });
6363
setTimeout(() => {
64-
expect(stdoutWrite.mock.calls[1][0]).toBe(` ◵ describe1`);
64+
expect(stdoutWrite.mock.calls[1][0]).toMatchSnapshot();
6565
emitter.emit('errorUnit');
66-
expect(stdoutWrite.mock.calls.slice(3).join('')).toBe(` 1) describe1\n`);
66+
expect(stdoutWrite.mock.calls.slice(3).join('')).toMatchSnapshot();
6767
done();
6868
}, utils.spinnerInterval + 1);
6969
});

packages/htte-reporter-cli/src/__tests__/utils.test.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const utils = require('../utils');
2+
const os = require('os');
23

34
utils.useColors = false;
45

@@ -52,28 +53,6 @@ describe('epilogue', function() {
5253
mockUnit(7, 'skip', true)
5354
];
5455
utils.epilogue({ units, duration: 4000 });
55-
expect(stdoutWrite.mock.calls.join('')).toBe(`
56-
3 passed (4s)
57-
2 pending
58-
2 failed
59-
60-
1) module2-> root-> grp2-> describe2
61-
at req•body, throw error: err2
62-
2) module6-> root-> grp6-> describe6
63-
at req•body, throw error: err6
64-
req:
65-
url: /p6
66-
body: req6
67-
res: {}
68-
69-
70-
module5-> root-> grp5-> describe5
71-
req:
72-
url: /p5
73-
body: req5
74-
res:
75-
body: res5
76-
77-
`);
56+
expect(stdoutWrite.mock.calls.join('')).toMatchSnapshot();
7857
});
7958
});

packages/htte-utils/src/__tests__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('completeUrlParams', function() {
5959
describe('tmpfile', function() {
6060
test('generate tmpfile ', function() {
6161
let tmpfile = utils.tmpfile(path.resolve(__dirname, 'htte-utils'));
62-
expect(tmpfile).toMatch(/\/tmp\/htte-utils-\w{6}\.json/);
62+
expect(tmpfile).toMatch(/htte-utils-\w{6}\.json$/);
6363
let newtmpfile = utils.tmpfile(path.resolve(__dirname, 'htte-utils'));
6464
expect(newtmpfile).toBe(tmpfile);
6565
});

0 commit comments

Comments
 (0)