Wait for static Server to start in tests
This patch starts waiting for Server's listening event before starting to run any tests.
This commit is contained in:
parent
c8664319ed
commit
bf08dbb3e9
@ -25,6 +25,17 @@ const fulfillSymbol = Symbol('fullfill callback');
|
||||
const rejectSymbol = Symbol('reject callback');
|
||||
|
||||
class StaticServer {
|
||||
/**
|
||||
* @param {string} dirPath
|
||||
* @param {number} port
|
||||
* @return {!StaticServer}
|
||||
*/
|
||||
static async create(dirPath, port) {
|
||||
let server = new StaticServer(dirPath, port);
|
||||
await new Promise(x => server._server.once('listening', x));
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} dirPath
|
||||
* @param {number} port
|
||||
|
@ -30,11 +30,11 @@ describe('Puppeteer', function() {
|
||||
let staticServer;
|
||||
let page;
|
||||
|
||||
beforeAll(function() {
|
||||
beforeAll(SX(async function() {
|
||||
browser = new Browser({args: ['--no-sandbox']});
|
||||
staticServer = new StaticServer(path.join(__dirname, 'assets'), PORT);
|
||||
staticServer = await StaticServer.create(path.join(__dirname, 'assets'), PORT);
|
||||
GoldenUtils.removeOutputDir();
|
||||
});
|
||||
}));
|
||||
|
||||
afterAll(function() {
|
||||
staticServer.stop();
|
||||
|
Loading…
Reference in New Issue
Block a user