mirror of
https://github.com/eggjs/egg.git
synced 2024-12-04 07:14:30 +00:00
For Nodejs 20, we should use "await" to wait each of these threads finishing their task and then for a coming result.
60 lines
1.4 KiB
JavaScript
60 lines
1.4 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const mm = require('egg-mock');
|
|
const utils = require('../../utils');
|
|
|
|
describe('test/lib/plugins/development.test.js', () => {
|
|
afterEach(mm.restore);
|
|
|
|
describe('development app', () => {
|
|
let app;
|
|
before(() => {
|
|
mm.env('local');
|
|
mm(process.env, 'EGG_LOG', 'none');
|
|
app = utils.app('apps/development');
|
|
return app.ready();
|
|
});
|
|
after(() => app.close());
|
|
|
|
it('should ignore assets', async () => {
|
|
mm(app.logger, 'info', msg => {
|
|
if (msg.match(/status /)) {
|
|
throw new Error('should not log status');
|
|
}
|
|
});
|
|
|
|
await app.httpRequest()
|
|
.get('/foo.js')
|
|
.expect(200);
|
|
|
|
await app.httpRequest()
|
|
.get('/public/hello');
|
|
|
|
await app.httpRequest()
|
|
.get('/assets/hello');
|
|
|
|
await app.httpRequest()
|
|
.get('/__koa_mock_scene_toolbox/hello');
|
|
});
|
|
});
|
|
|
|
describe('reload workers', () => {
|
|
let app;
|
|
const baseDir = utils.getFilepath('apps/reload-worker');
|
|
const filepath = path.join(baseDir, 'app/controller/home.js');
|
|
const body = fs.readFileSync(filepath);
|
|
|
|
before(() => {
|
|
mm.env('local');
|
|
app = utils.cluster('apps/reload-worker');
|
|
app.debug();
|
|
app.coverage(false);
|
|
return app.ready();
|
|
});
|
|
after(() => app.close());
|
|
after(() => {
|
|
fs.writeFileSync(filepath, body);
|
|
});
|
|
});
|
|
});
|