mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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');
|
const rejectSymbol = Symbol('reject callback');
|
||||||
|
|
||||||
class StaticServer {
|
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 {string} dirPath
|
||||||
* @param {number} port
|
* @param {number} port
|
||||||
|
@ -30,11 +30,11 @@ describe('Puppeteer', function() {
|
|||||||
let staticServer;
|
let staticServer;
|
||||||
let page;
|
let page;
|
||||||
|
|
||||||
beforeAll(function() {
|
beforeAll(SX(async function() {
|
||||||
browser = new Browser({args: ['--no-sandbox']});
|
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();
|
GoldenUtils.removeOutputDir();
|
||||||
});
|
}));
|
||||||
|
|
||||||
afterAll(function() {
|
afterAll(function() {
|
||||||
staticServer.stop();
|
staticServer.stop();
|
||||||
|
Loading…
Reference in New Issue
Block a user