Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable app close on parallel #160

Merged
merged 3 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions register.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ exports.mochaHooks = {
await mock.restore();
},
async afterAll() {
// skip auto app close on parallel
if (process.env.ENABLE_MOCHA_PARALLEL) return;
const app = await appHandler.getApp();
debug('mochaHooks.afterAll call, _app: %s', app);
if (app) {
Expand Down
27 changes: 11 additions & 16 deletions test/inject_ctx.test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
const coffee = require('coffee');
const path = require('path');

describe.only('test/inject_ctx.test.js', () => {
describe('test/inject_ctx.test.js', () => {
const eggBinFile = require.resolve('egg-bin//dist/bin/cli');

it('should inject ctx to runner', async () => {
const fixture = path.join(__dirname, 'fixtures/tegg-app');

await coffee.fork(require.resolve('egg-bin/bin/egg-bin'), [
await coffee.fork(eggBinFile, [
'test',
'-r', require.resolve('../register'),
'--full-trace',
], {
cwd: fixture,
env: {
EGG_FRAMEWORK: require.resolve('egg'),
},
})
.debug()
// .debug()
.expect('code', 0)
.expect('stdout', /10 passing/)
.end();
Expand All @@ -24,10 +25,9 @@ describe.only('test/inject_ctx.test.js', () => {
it('should inject ctx to runner with setGetAppCallback', async () => {
const fixture = path.join(__dirname, 'fixtures/setup-app');

await coffee.fork(require.resolve('egg-bin/bin/egg-bin'), [
await coffee.fork(eggBinFile, [
'test',
'-r', require.resolve('../register'),
'--full-trace',
], {
cwd: fixture,
})
Expand All @@ -40,10 +40,9 @@ describe.only('test/inject_ctx.test.js', () => {
it('hook/case error should failed', async () => {
const fixture = path.join(__dirname, 'fixtures/failed-app');

await coffee.fork(require.resolve('egg-bin/bin/egg-bin'), [
await coffee.fork(eggBinFile, [
'test',
'-r', require.resolve('../register'),
'--full-trace',
], {
cwd: fixture,
env: {
Expand All @@ -68,10 +67,9 @@ describe.only('test/inject_ctx.test.js', () => {
it('get app error should failed', async () => {
const fixture = path.join(__dirname, 'fixtures/get-app-failed');

await coffee.fork(require.resolve('egg-bin/bin/egg-bin'), [
await coffee.fork(eggBinFile, [
'test',
'-r', require.resolve('../register'),
'--full-trace',
], {
cwd: fixture,
env: {
Expand All @@ -87,10 +85,9 @@ describe.only('test/inject_ctx.test.js', () => {
it('create context error should failed', async () => {
const fixture = path.join(__dirname, 'fixtures/create-context-failed');

await coffee.fork(require.resolve('egg-bin/bin/egg-bin'), [
await coffee.fork(eggBinFile, [
'test',
'-r', require.resolve('../register'),
'--full-trace',
], {
cwd: fixture,
env: {
Expand All @@ -108,10 +105,9 @@ describe.only('test/inject_ctx.test.js', () => {
it('get app error should failed', async () => {
const fixture = path.join(__dirname, 'fixtures/test-case-get-app-failed');

await coffee.fork(require.resolve('egg-bin/bin/egg-bin'), [
await coffee.fork(eggBinFile, [
'test',
'-r', require.resolve('../register'),
'--full-trace',
], {
cwd: fixture,
env: {
Expand All @@ -127,10 +123,9 @@ describe.only('test/inject_ctx.test.js', () => {
it('create context error should failed', async () => {
const fixture = path.join(__dirname, 'fixtures/test-case-create-context-failed');

await coffee.fork(require.resolve('egg-bin/bin/egg-bin'), [
await coffee.fork(eggBinFile, [
'test',
'-r', require.resolve('../register'),
'--full-trace',
], {
cwd: fixture,
env: {
Expand Down