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

add python support#377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 4 commits intomasterfromfeature/python
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsrc/services/testRunner/formatOutput.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import{ParserOutput,Fail}from'./parser'

// TODO: implement better successouput
// TODO: implement better successoutput
// export const formatSuccessOutput = (tap: ParserOutput): string => {}

exportconstformatFailOutput=(tap:ParserOutput):string=>{
Expand Down
242 changes: 162 additions & 80 deletionssrc/services/testRunner/parser.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,71 @@
import parser from './parser'

describe('parser', () => {
test('should pass single success', () => {
const example = `
describe('mocha', () => {
test('should pass single success', () => {
const example = `
1..1
ok 1 - Should pass
`
expect(parser(example)).toEqual({
ok: true,
passed: [{ message: 'Should pass' }],
failed: [],
logs: [],
summary: { 'Should pass': true },
expect(parser(example)).toEqual({
ok: true,
passed: [{ message: 'Should pass' }],
failed: [],
logs: [],
summary: { 'Should pass': true },
})
})
})
test('should detect multiple successes', () => {
const example = `
test('should detect multiple successes', () => {
const example = `
1..2
ok 1 - Should pass
ok 2 - Should also pass
`
const result = parser(example)
expect(result).toEqual({
ok: true,
passed: [{ message: 'Should pass' }, { message: 'Should also pass' }],
failed: [],
logs: [],
summary: {
'Should pass': true,
'Should also pass': true,
},
const result = parser(example)
expect(result).toEqual({
ok: true,
passed: [{ message: 'Should pass' }, { message: 'Should also pass' }],
failed: [],
logs: [],
summary: {
'Should pass': true,
'Should also pass': true,
},
})
})
})
test('should detect failure if no tests passed', () => {
const example = `
test('should detect failure if no tests passed', () => {
const example = `
# Starting...
# 1 test suites found.

# FAIL __tests__/sum.test.js

not ok 1 ● sum › should add two numbers together
`
expect(parser(example).ok).toBe(false)
})
test('should detect single failure among successes', () => {
const example = `
expect(parser(example).ok).toBe(false)
})
test('should detect single failure among successes', () => {
const example = `
1..3
ok 1 - Should pass
not ok 2 - This one fails
ok 3 - Also passes
`
expect(parser(example).ok).toBe(false)
})
test('should return failure message', () => {
const example = `
expect(parser(example).ok).toBe(false)
})
test('should return failure message', () => {
const example = `
1..4
ok 1 - Should pass
not ok 2 - First to fail
ok 3 - Also passes
not ok 4 - Second to fail
`
expect(parser(example).failed).toEqual([{ message: 'First to fail' }, { message: 'Second to fail' }])
})
expect(parser(example).failed).toEqual([{ message: 'First to fail' }, { message: 'Second to fail' }])
})

test('should parse mocha tap example', () => {
const example = `
test('should parse mocha tap example', () => {
const example = `
1..3
ok 1 itemList data should not be changed
ok 2 sumItems shouldn't return NaN
Expand All@@ -74,11 +75,11 @@ ok 3 sumItems should total numbers accurately
# fail 0
# skip 0
`
expect(parser(example).ok).toBe(true)
})
expect(parser(example).ok).toBe(true)
})

test('should return failure message for mocha tap example', () => {
const example = `
test('should return failure message for mocha tap example', () => {
const example = `
1..3
ok 1 itemList data should not be changed
not ok 2 sumItems shouldn't return NaN
Expand All@@ -88,10 +89,10 @@ ok 3 sumItems should total numbers accurately
# fail 1
# skip 0
`
expect(parser(example).failed).toEqual([{ message: "sumItems shouldn't return NaN" }])
})
test('should capture single error details', () => {
const example = `
expect(parser(example).failed).toEqual([{ message: "sumItems shouldn't return NaN" }])
})
test('should capture single error details', () => {
const example = `
not ok 1 package.json should have a valid "author" key
# AssertionError [ERR_ASSERTION]: no "author" key provided
# at Context.<anonymous> (test/packagejson.test.js:11:12)
Expand All@@ -101,14 +102,14 @@ not ok 1 package.json should have a valid "author" key
# fail 1
# skip 0
`
const result = parser(example)
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
const result = parser(example)
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
at Context.<anonymous> (test/packagejson.test.js:11:12)
at processImmediate (internal/timers.js:439:21)`)
})
test('should capture multiple error details', () => {
const example = `
})
test('should capture multiple error details', () => {
const example = `
not ok 1 package.json should have a valid "author" key
# AssertionError [ERR_ASSERTION]: no "author" key provided
# at Context.<anonymous> (test/packagejson.test.js:11:12)
Expand All@@ -120,16 +121,16 @@ not ok 2 package.json should have a valid "description" key
# fail 1
# skip 0
`
const result = parser(example)
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
const result = parser(example)
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
at Context.<anonymous> (test/packagejson.test.js:11:12)
at processImmediate (internal/timers.js:439:21)`)
expect(result.failed[1].message).toBe('package.json should have a valid "description" key')
expect(result.failed[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
})
test('should capture multiple error details between successes', () => {
const example = `
expect(result.failed[1].message).toBe('package.json should have a valid "description" key')
expect(result.failed[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
})
test('should capture multiple error details between successes', () => {
const example = `
ok 1 first passing test
not ok 2 package.json should have a valid "author" key
# AssertionError [ERR_ASSERTION]: no "author" key provided
Expand All@@ -144,16 +145,16 @@ ok 5 some passing test
# fail 1
# skip 0
`
const result = parser(example)
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
const result = parser(example)
expect(result.failed[0].message).toBe('package.json should have a valid "author" key')
expect(result.failed[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
at Context.<anonymous> (test/packagejson.test.js:11:12)
at processImmediate (internal/timers.js:439:21)`)
expect(result.failed[1].message).toBe('package.json should have a valid "description" key')
expect(result.failed[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
})
test('should capture logs', () => {
const example = `
expect(result.failed[1].message).toBe('package.json should have a valid "description" key')
expect(result.failed[1].details).toBe(`AssertionError [ERR_ASSERTION]: no "description" key provided`)
})
test('should capture logs', () => {
const example = `
1..2
ok 1 package.json should have "express" installed
log 1
Expand All@@ -167,23 +168,104 @@ not ok 2 server should log "Hello World"
# fail 1
# skip 0
`
expect(parser(example)).toEqual({
ok: false,
passed: [{ message: 'package.json should have "express" installed' }],
failed: [
{
message: 'server should log "Hello World"',
details: `AssertionError [ERR_ASSERTION]: \"Hello World was not logged
expect(parser(example)).toEqual({
ok: false,
passed: [{ message: 'package.json should have "express" installed' }],
failed: [
{
message: 'server should log "Hello World"',
details: `AssertionError [ERR_ASSERTION]: \"Hello World was not logged
at Context.<anonymous> (test/server.test.js:15:12)
at processImmediate (internal/timers.js:439:21)`,
logs: ['log 1', 'log 2'],
logs: ['log 1', 'log 2'],
},
],
logs: ['log 1', 'log 2'],
summary: {
'package.json should have "express" installed': true,
'server should log "Hello World"': false,
},
})
})
})
describe('tap.py', () => {
test('should pass with success messages', () => {
const example = `
# TAP results for MathTest
ok 1 test_add_no_numbers (tests.math_test.MathTest)
ok 2 test_add_one_number (tests.math_test.MathTest)
ok 3 test_add_three_numbers (tests.math_test.MathTest)
ok 4 test_add_two_numbers (tests.math_test.MathTest)
1..4
`
expect(parser(example)).toEqual({
ok: true,
passed: [
{ message: 'add no numbers' },
{ message: 'add one number' },
{ message: 'add three numbers' },
{ message: 'add two numbers' },
],
failed: [],
logs: [],
summary: {
'add no numbers': true,
'add one number': true,
'add three numbers': true,
'add two numbers': true,
},
})
})
test('should handle fail messages', () => {
const example = `
# TAP results for MathTest
not ok 1 test_add_no_numbers (tests.math_test.MathTest)
# Traceback (most recent call last):
# Fail Message
# AssertionError: 42 != 0 : Should return 0 with no params
1..1`
expect(parser(example)).toEqual({
ok: false,
passed: [],
failed: [
{
message: 'add no numbers',
details:
'Traceback (most recent call last):\nFail Message\nAssertionError: 42 != 0 : Should return 0 with no params',
},
],
logs: [],
summary: {
'add no numbers': false,
},
})
})
test('should handle both success and fail messages', () => {
const example = `
# TAP results for MathTest
ok 1 test_add_no_numbers (tests.math_test.MathTest)
not ok 2 test_add_one_number (tests.math_test.MathTest)
# Traceback (most recent call last):
# Fail Message
# AssertionError: 2 != 1 : Should add one number to 0
1..2
`
expect(parser(example)).toEqual({
ok: false,
passed: [{ message: 'add no numbers' }],
failed: [
{
message: 'add one number',
details:
'Traceback (most recent call last):\nFail Message\nAssertionError: 2 != 1 : Should add one number to 0',
},
],
logs: [],
summary: {
'add no numbers': true,
'add one number': false,
},
],
logs: ['log 1', 'log 2'],
summary: {
'package.json should have "express" installed': true,
'server should log "Hello World"': false,
},
})
})
})
})
Loading

[8]ページ先頭

©2009-2025 Movatter.jp