mirror of
https://github.com/fluencelabs/examples
synced 2025-06-10 16:41:21 +00:00
starting inline server inside tests
This commit is contained in:
parent
f7bc5bdc97
commit
7bb0900713
1053
fluence-js-examples/browser-example/package-lock.json
generated
1053
fluence-js-examples/browser-example/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@
|
||||
"@types/node": "^12.20.16",
|
||||
"@types/react": "^17.0.14",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"@types/serve-handler": "^6.1.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "^5.0.0",
|
||||
@ -23,8 +24,8 @@
|
||||
"prestart": "npm run compile-aqua",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"test-e2e": "jest --config=jest.config.js",
|
||||
"test": "jest --config=jest.config.js",
|
||||
"_test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"compile-aqua": "aqua -i ./aqua/ -o ./src/_aqua",
|
||||
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
|
||||
@ -39,7 +40,9 @@
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
"not op_mini all",
|
||||
"not ie 11",
|
||||
"not android 4.4.3-4.4.4"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
@ -55,6 +58,7 @@
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"jest-puppeteer": "^6.0.2",
|
||||
"node-sass": "^6.0.1",
|
||||
"serve": "^13.0.2",
|
||||
"ts-jest": "^27.1.3"
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
990
quickstart/1-browser-to-browser/package-lock.json
generated
990
quickstart/1-browser-to-browser/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,6 +12,7 @@
|
||||
"@types/node": "^12.20.16",
|
||||
"@types/react": "^17.0.14",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"@types/serve-handler": "^6.1.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "^5.0.0",
|
||||
@ -23,8 +24,8 @@
|
||||
"prestart": "npm run compile-aqua",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"test-e2e": "jest --config=jest.config.js",
|
||||
"test": "jest --config=jest.config.js",
|
||||
"_test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"compile-aqua": "aqua -i ./aqua/ -o ./src/_aqua",
|
||||
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
|
||||
@ -39,7 +40,9 @@
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
"not op_mini all",
|
||||
"not ie 11",
|
||||
"not android 4.4.3-4.4.4"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
@ -55,6 +58,7 @@
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"jest-puppeteer": "^6.0.2",
|
||||
"node-sass": "^6.0.1",
|
||||
"serve": "^13.0.2",
|
||||
"ts-jest": "^27.1.3"
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
977
quickstart/3-browser-to-service/package-lock.json
generated
977
quickstart/3-browser-to-service/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -23,8 +23,8 @@
|
||||
"prestart": "npm run compile-aqua",
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"test-e2e": "jest --config=jest.config.js",
|
||||
"test": "jest --config=jest.config.js",
|
||||
"_test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"compile-aqua": "aqua -i ./aqua/ -o ./src/_aqua",
|
||||
"watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\""
|
||||
@ -39,7 +39,9 @@
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
"not op_mini all",
|
||||
"not ie 11",
|
||||
"not android 4.4.3-4.4.4"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
@ -52,9 +54,11 @@
|
||||
"@fluencelabs/aqua-lib": "^0.4.0",
|
||||
"@types/jest-environment-puppeteer": "^4.4.1",
|
||||
"@types/puppeteer": "^5.4.4",
|
||||
"@types/serve-handler": "^6.1.1",
|
||||
"chokidar-cli": "^2.1.0",
|
||||
"jest-puppeteer": "^6.0.2",
|
||||
"node-sass": "^6.0.1",
|
||||
"serve": "^13.0.2",
|
||||
"ts-jest": "^27.1.3"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,31 @@
|
||||
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) => {
|
||||
@ -34,6 +60,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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user