starting inline server inside tests

This commit is contained in:
Pavel Murygin
2022-02-17 20:46:45 +03:00
parent f7bc5bdc97
commit 7bb0900713
9 changed files with 3099 additions and 49 deletions

View File

@ -1,7 +1,40 @@
import handler from 'serve-handler';
import http from 'http';
import path from 'path';
const port = 3000;
const uri = `http://localhost:${port}/`
const publicPath = path.join(__dirname, '../../build/');
console.log(publicPath);
const server = http.createServer((request, response) => {
return handler(request, response, {
public: publicPath
});
})
const startServer = async () => {
return new Promise((resolve: any) => {
server.listen(3000, resolve);
})
}
const stopServer = async () => {
return new Promise((resolve: any) => {
server.close(resolve);
})
}
describe('smoke test', () => {
beforeAll(startServer);
afterAll(stopServer);
it('should work', async () => {
console.log('going to the page in browser...');
await page.goto('http://localhost:3000/');
await page.goto(uri);
console.log('waiting for fluence to connect...');
await page.waitForTimeout(1000);