Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit91d234f

Browse files
authored
Merge pull request#377 from coderoad/feature/python
add python support
2 parentsba15a00 +427a7b3 commit91d234f

File tree

4 files changed

+198
-99
lines changed

4 files changed

+198
-99
lines changed

‎src/services/testRunner/formatOutput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{ParserOutput,Fail}from'./parser'
22

3-
// TODO: implement better successouput
3+
// TODO: implement better successoutput
44
// export const formatSuccessOutput = (tap: ParserOutput): string => {}
55

66
exportconstformatFailOutput=(tap:ParserOutput):string=>{
Lines changed: 162 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,71 @@
11
importparserfrom'./parser'
22

33
describe('parser',()=>{
4-
test('should pass single success',()=>{
5-
constexample=`
4+
describe('mocha',()=>{
5+
test('should pass single success',()=>{
6+
constexample=`
67
1..1
78
ok 1 - Should pass
89
`
9-
expect(parser(example)).toEqual({
10-
ok:true,
11-
passed:[{message:'Should pass'}],
12-
failed:[],
13-
logs:[],
14-
summary:{'Should pass':true},
10+
expect(parser(example)).toEqual({
11+
ok:true,
12+
passed:[{message:'Should pass'}],
13+
failed:[],
14+
logs:[],
15+
summary:{'Should pass':true},
16+
})
1517
})
16-
})
17-
test('should detect multiple successes',()=>{
18-
constexample=`
18+
test('should detect multiple successes',()=>{
19+
constexample=`
1920
1..2
2021
ok 1 - Should pass
2122
ok 2 - Should also pass
2223
`
23-
constresult=parser(example)
24-
expect(result).toEqual({
25-
ok:true,
26-
passed:[{message:'Should pass'},{message:'Should also pass'}],
27-
failed:[],
28-
logs:[],
29-
summary:{
30-
'Should pass':true,
31-
'Should also pass':true,
32-
},
24+
constresult=parser(example)
25+
expect(result).toEqual({
26+
ok:true,
27+
passed:[{message:'Should pass'},{message:'Should also pass'}],
28+
failed:[],
29+
logs:[],
30+
summary:{
31+
'Should pass':true,
32+
'Should also pass':true,
33+
},
34+
})
3335
})
34-
})
35-
test('should detect failure if no tests passed',()=>{
36-
constexample=`
36+
test('should detect failure if no tests passed',()=>{
37+
constexample=`
3738
# Starting...
3839
# 1 test suites found.
3940
4041
# FAIL __tests__/sum.test.js
4142
4243
not ok 1 ● sum › should add two numbers together
4344
`
44-
expect(parser(example).ok).toBe(false)
45-
})
46-
test('should detect single failure among successes',()=>{
47-
constexample=`
45+
expect(parser(example).ok).toBe(false)
46+
})
47+
test('should detect single failure among successes',()=>{
48+
constexample=`
4849
1..3
4950
ok 1 - Should pass
5051
not ok 2 - This one fails
5152
ok 3 - Also passes
5253
`
53-
expect(parser(example).ok).toBe(false)
54-
})
55-
test('should return failure message',()=>{
56-
constexample=`
54+
expect(parser(example).ok).toBe(false)
55+
})
56+
test('should return failure message',()=>{
57+
constexample=`
5758
1..4
5859
ok 1 - Should pass
5960
not ok 2 - First to fail
6061
ok 3 - Also passes
6162
not ok 4 - Second to fail
6263
`
63-
expect(parser(example).failed).toEqual([{message:'First to fail'},{message:'Second to fail'}])
64-
})
64+
expect(parser(example).failed).toEqual([{message:'First to fail'},{message:'Second to fail'}])
65+
})
6566

66-
test('should parse mocha tap example',()=>{
67-
constexample=`
67+
test('should parse mocha tap example',()=>{
68+
constexample=`
6869
1..3
6970
ok 1 itemList data should not be changed
7071
ok 2 sumItems shouldn't return NaN
@@ -74,11 +75,11 @@ ok 3 sumItems should total numbers accurately
7475
# fail 0
7576
# skip 0
7677
`
77-
expect(parser(example).ok).toBe(true)
78-
})
78+
expect(parser(example).ok).toBe(true)
79+
})
7980

80-
test('should return failure message for mocha tap example',()=>{
81-
constexample=`
81+
test('should return failure message for mocha tap example',()=>{
82+
constexample=`
8283
1..3
8384
ok 1 itemList data should not be changed
8485
not ok 2 sumItems shouldn't return NaN
@@ -88,10 +89,10 @@ ok 3 sumItems should total numbers accurately
8889
# fail 1
8990
# skip 0
9091
`
91-
expect(parser(example).failed).toEqual([{message:"sumItems shouldn't return NaN"}])
92-
})
93-
test('should capture single error details',()=>{
94-
constexample=`
92+
expect(parser(example).failed).toEqual([{message:"sumItems shouldn't return NaN"}])
93+
})
94+
test('should capture single error details',()=>{
95+
constexample=`
9596
not ok 1 package.json should have a valid "author" key
9697
# AssertionError [ERR_ASSERTION]: no "author" key provided
9798
# at Context.<anonymous> (test/packagejson.test.js:11:12)
@@ -101,14 +102,14 @@ not ok 1 package.json should have a valid "author" key
101102
# fail 1
102103
# skip 0
103104
`
104-
constresult=parser(example)
105-
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
106-
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
105+
constresult=parser(example)
106+
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
107+
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
107108
at Context.<anonymous> (test/packagejson.test.js:11:12)
108109
at processImmediate (internal/timers.js:439:21)`)
109-
})
110-
test('should capture multiple error details',()=>{
111-
constexample=`
110+
})
111+
test('should capture multiple error details',()=>{
112+
constexample=`
112113
not ok 1 package.json should have a valid "author" key
113114
# AssertionError [ERR_ASSERTION]: no "author" key provided
114115
# at Context.<anonymous> (test/packagejson.test.js:11:12)
@@ -120,16 +121,16 @@ not ok 2 package.json should have a valid "description" key
120121
# fail 1
121122
# skip 0
122123
`
123-
constresult=parser(example)
124-
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
125-
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
124+
constresult=parser(example)
125+
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
126+
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
126127
at Context.<anonymous> (test/packagejson.test.js:11:12)
127128
at processImmediate (internal/timers.js:439:21)`)
128-
expect(result.failed[1].message).toBe('package.json should have a valid "description" key')
129-
expect(result.failed[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
130-
})
131-
test('should capture multiple error details between successes',()=>{
132-
constexample=`
129+
expect(result.failed[1].message).toBe('package.json should have a valid "description" key')
130+
expect(result.failed[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
131+
})
132+
test('should capture multiple error details between successes',()=>{
133+
constexample=`
133134
ok 1 first passing test
134135
not ok 2 package.json should have a valid "author" key
135136
# AssertionError [ERR_ASSERTION]: no "author" key provided
@@ -144,16 +145,16 @@ ok 5 some passing test
144145
# fail 1
145146
# skip 0
146147
`
147-
constresult=parser(example)
148-
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
149-
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
148+
constresult=parser(example)
149+
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
150+
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
150151
at Context.<anonymous> (test/packagejson.test.js:11:12)
151152
at processImmediate (internal/timers.js:439:21)`)
152-
expect(result.failed[1].message).toBe('package.json should have a valid "description" key')
153-
expect(result.failed[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
154-
})
155-
test('should capture logs',()=>{
156-
constexample=`
153+
expect(result.failed[1].message).toBe('package.json should have a valid "description" key')
154+
expect(result.failed[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
155+
})
156+
test('should capture logs',()=>{
157+
constexample=`
157158
1..2
158159
ok 1 package.json should have "express" installed
159160
log 1
@@ -167,23 +168,104 @@ not ok 2 server should log "Hello World"
167168
# fail 1
168169
# skip 0
169170
`
170-
expect(parser(example)).toEqual({
171-
ok:false,
172-
passed:[{message:'package.json should have "express" installed'}],
173-
failed:[
174-
{
175-
message:'server should log "Hello World"',
176-
details:`AssertionError [ERR_ASSERTION]: \"Hello World was not logged
171+
expect(parser(example)).toEqual({
172+
ok:false,
173+
passed:[{message:'package.json should have "express" installed'}],
174+
failed:[
175+
{
176+
message:'server should log "Hello World"',
177+
details:`AssertionError [ERR_ASSERTION]: \"Hello World was not logged
177178
at Context.<anonymous> (test/server.test.js:15:12)
178179
at processImmediate (internal/timers.js:439:21)`,
179-
logs:['log 1','log 2'],
180+
logs:['log 1','log 2'],
181+
},
182+
],
183+
logs:['log 1','log 2'],
184+
summary:{
185+
'package.json should have "express" installed':true,
186+
'server should log "Hello World"':false,
187+
},
188+
})
189+
})
190+
})
191+
describe('tap.py',()=>{
192+
test('should pass with success messages',()=>{
193+
constexample=`
194+
# TAP results for MathTest
195+
ok 1 test_add_no_numbers (tests.math_test.MathTest)
196+
ok 2 test_add_one_number (tests.math_test.MathTest)
197+
ok 3 test_add_three_numbers (tests.math_test.MathTest)
198+
ok 4 test_add_two_numbers (tests.math_test.MathTest)
199+
1..4
200+
`
201+
expect(parser(example)).toEqual({
202+
ok:true,
203+
passed:[
204+
{message:'add no numbers'},
205+
{message:'add one number'},
206+
{message:'add three numbers'},
207+
{message:'add two numbers'},
208+
],
209+
failed:[],
210+
logs:[],
211+
summary:{
212+
'add no numbers':true,
213+
'add one number':true,
214+
'add three numbers':true,
215+
'add two numbers':true,
216+
},
217+
})
218+
})
219+
test('should handle fail messages',()=>{
220+
constexample=`
221+
# TAP results for MathTest
222+
not ok 1 test_add_no_numbers (tests.math_test.MathTest)
223+
# Traceback (most recent call last):
224+
# Fail Message
225+
# AssertionError: 42 != 0 : Should return 0 with no params
226+
1..1`
227+
expect(parser(example)).toEqual({
228+
ok:false,
229+
passed:[],
230+
failed:[
231+
{
232+
message:'add no numbers',
233+
details:
234+
'Traceback (most recent call last):\nFail Message\nAssertionError: 42 != 0 : Should return 0 with no params',
235+
},
236+
],
237+
logs:[],
238+
summary:{
239+
'add no numbers':false,
240+
},
241+
})
242+
})
243+
test('should handle both success and fail messages',()=>{
244+
constexample=`
245+
# TAP results for MathTest
246+
ok 1 test_add_no_numbers (tests.math_test.MathTest)
247+
not ok 2 test_add_one_number (tests.math_test.MathTest)
248+
# Traceback (most recent call last):
249+
# Fail Message
250+
# AssertionError: 2 != 1 : Should add one number to 0
251+
1..2
252+
`
253+
expect(parser(example)).toEqual({
254+
ok:false,
255+
passed:[{message:'add no numbers'}],
256+
failed:[
257+
{
258+
message:'add one number',
259+
details:
260+
'Traceback (most recent call last):\nFail Message\nAssertionError: 2 != 1 : Should add one number to 0',
261+
},
262+
],
263+
logs:[],
264+
summary:{
265+
'add no numbers':true,
266+
'add one number':false,
180267
},
181-
],
182-
logs:['log 1','log 2'],
183-
summary:{
184-
'package.json should have "express" installed':true,
185-
'server should log "Hello World"':false,
186-
},
268+
})
187269
})
188270
})
189271
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp