Skip to content
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
3 changes: 0 additions & 3 deletions test/fixtures/pkg-config/inject.js

This file was deleted.

3 changes: 3 additions & 0 deletions test/fixtures/pkg-config/inject1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

console.log('@@@ inject script1');
2 changes: 1 addition & 1 deletion test/fixtures/pkg-config/inject2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';

console.log('@@@ inject by cli');
console.log('@@@ inject script2');
2 changes: 1 addition & 1 deletion test/fixtures/pkg-config/node_modules/inject/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/pkg-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"eggScriptsConfig": {
"require": [
"./inject.js",
"./inject1.js",
"inject"
]
}
Expand Down
19 changes: 15 additions & 4 deletions test/start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,27 @@ describe('test/start.test.js', () => {
});

it('should --require', function* () {
app = coffee.fork(eggBin, [ 'start', '--workers=1', '--require=./inject2' ], { cwd: fixturePath });
app = coffee.fork(eggBin, [ 'start', '--workers=1', '--require=./inject2.js' ], { cwd: fixturePath });
app.debug();
app.expect('code', 0);

yield sleep(waitTime);

assert(app.stderr === '');
assert(app.stdout.match(/@@@ inject relative js by pkgInfo/));
assert(app.stdout.match(/@@@ inject node_modules by pkgInfo/));
assert(app.stdout.match(/@@@ inject by cli/));
assert(app.stdout.match(/@@@ inject script/));
assert(app.stdout.match(/@@@ inject script1/));
assert(app.stdout.match(/@@@ inject script2/));
});

it('inject incorrect script', function* () {
const script = './inject3.js';
app = coffee.fork(eggBin, [ 'start', '--workers=1', `--require=${script}` ], { cwd: fixturePath });
app.debug();
app.expect('code', 0);

yield sleep(waitTime);

assert(app.stderr.includes(`Cannot find module '${path.join(fixturePath, script)}'`));
});
});

Expand Down