mirror of
https://github.com/fluencelabs/examples
synced 2025-06-21 13:51:32 +00:00
starting inline server inside tests
This commit is contained in:
@ -1,10 +1,37 @@
|
||||
import { Page } from 'puppeteer';
|
||||
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);
|
||||
})
|
||||
}
|
||||
|
||||
const peerIdLength = '12D3KooWM2CYSHefG6KPKbYFAgsbPh8p6b8HYHc6VNkge2rPtYv5'.length;
|
||||
|
||||
const loadApp = async (page: Page) => {
|
||||
console.log('opening page...');
|
||||
await page.goto('http://localhost:3000/');
|
||||
await page.goto(uri);
|
||||
|
||||
console.log('clicking connect button...');
|
||||
await page.click('.btn');
|
||||
@ -34,6 +61,10 @@ const waitForSelectorAndGetText = async (page: Page, selector: string) => {
|
||||
};
|
||||
|
||||
describe('smoke test', () => {
|
||||
beforeAll(startServer);
|
||||
|
||||
afterAll(stopServer);
|
||||
|
||||
it('should work', async () => {
|
||||
const page1 = await browser.newPage();
|
||||
const page2 = await browser.newPage();
|
||||
|
Reference in New Issue
Block a user