-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: inject failed should make suite/test failed (#154)
- Loading branch information
Showing
16 changed files
with
279 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
keys: '123', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "app" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { setGetAppCallback } = require('../../../..'); | ||
|
||
setGetAppCallback(() => { | ||
return { | ||
ready: async () => { | ||
// ... | ||
}, | ||
mockContextScope: async () => { | ||
throw new Error('mock create context failed'); | ||
}, | ||
}; | ||
}); | ||
|
||
describe('test case create context error', () => { | ||
it('should not print', () => { | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,53 @@ | ||
const assert = require('assert'); | ||
const { app } = require('../../../../bootstrap'); | ||
|
||
describe('test/index.test.ts', () => { | ||
describe('hook error', () => { | ||
describe('before error', () => { | ||
before(() => { | ||
throw new Error('before error'); | ||
}); | ||
|
||
it('should not print', () => { | ||
assert.fail('never arrive'); | ||
}); | ||
}); | ||
|
||
describe('after error', () => { | ||
after(() => { | ||
throw new Error('after error'); | ||
}); | ||
|
||
it('should print', () => { | ||
console.log('after error test case should print'); | ||
}); | ||
}); | ||
|
||
describe('beforeEach error', () => { | ||
beforeEach(() => { | ||
assert.fail('failed hook'); | ||
throw new Error('beforeEach error'); | ||
}); | ||
|
||
it('should fail', () => { | ||
// eslint-disable-next-line no-undef | ||
assert(app.currentContext); | ||
assert.fail('failed case'); | ||
it('should not print', () => { | ||
assert.fail('never arrive'); | ||
}); | ||
}); | ||
|
||
describe('mockContext failed', () => { | ||
before(() => { | ||
app.mockContextScope = () => { | ||
throw new Error('mockContextScope error'); | ||
}; | ||
describe('afterEach error', () => { | ||
afterEach(() => { | ||
throw new Error('afterEach error'); | ||
}); | ||
|
||
it('foo', () => { | ||
//... | ||
it('should print', () => { | ||
console.log('afterEach error test case should print'); | ||
}); | ||
}); | ||
|
||
describe('case error', () => { | ||
it('should failed', () => { | ||
assert.fail('should fail'); | ||
}); | ||
|
||
it('should not run', () => { | ||
console.log('it should not run'); | ||
it('should work', () => { | ||
// ... | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
keys: '123', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "app" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { setGetAppCallback } = require('../../../..'); | ||
|
||
setGetAppCallback(() => { | ||
throw new Error('mock get app failed'); | ||
}); | ||
|
||
describe('test case create context error', () => { | ||
it('should not print', () => { | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/fixtures/test-case-create-context-failed/config/config.default.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
keys: '123', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "app" | ||
} |
21 changes: 21 additions & 0 deletions
21
test/fixtures/test-case-create-context-failed/test/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const { setGetAppCallback } = require('../../../..'); | ||
|
||
setGetAppCallback((suite, test) => { | ||
return { | ||
ready: async () => { | ||
// ... | ||
}, | ||
mockContextScope: async scope => { | ||
if (!test) { | ||
await scope({}); | ||
} else { | ||
throw new Error('mock create context failed'); | ||
} | ||
}, | ||
}; | ||
}); | ||
|
||
describe('test case create context error', function() { | ||
it('should not print', () => { | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
test/fixtures/test-case-get-app-failed/config/config.default.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
keys: '123', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "app" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { setGetAppCallback } = require('../../../..'); | ||
|
||
setGetAppCallback((suite, test) => { | ||
if (test) { | ||
throw new Error('mock get app failed'); | ||
} | ||
return { | ||
ready: async () => { | ||
// ... | ||
}, | ||
mockContextScope: async scope => { | ||
await scope({}); | ||
}, | ||
}; | ||
}); | ||
|
||
describe('test case get app error', () => { | ||
it('should not print', () => { | ||
}); | ||
}); |
Oops, something went wrong.