mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: get port from created server (#11495)
This commit is contained in:
parent
e82cb47623
commit
d2f4b9ca53
@ -8,7 +8,7 @@
|
|||||||
"dev:test": "npm run test --watch",
|
"dev:test": "npm run test --watch",
|
||||||
"dev": "npm run build --watch",
|
"dev": "npm run build --watch",
|
||||||
"sandbox:test": "node tools/sandbox.js --test",
|
"sandbox:test": "node tools/sandbox.js --test",
|
||||||
"sandbox": "node tools/sandbox.js",
|
"sandbox": "node tools/sandbox.mjs",
|
||||||
"test": "wireit",
|
"test": "wireit",
|
||||||
"test:smoke": "wireit"
|
"test:smoke": "wireit"
|
||||||
},
|
},
|
||||||
@ -24,7 +24,8 @@
|
|||||||
],
|
],
|
||||||
"output": [
|
"output": [
|
||||||
"lib/**",
|
"lib/**",
|
||||||
"test/build/**"
|
"test/build/**",
|
||||||
|
"*.tsbuildinfo"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
|
@ -73,7 +73,11 @@ function updateExecutablePath(command: string, root?: string) {
|
|||||||
return normalize(path);
|
return normalize(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function executeCommand(context: BuilderContext, command: string[]) {
|
async function executeCommand(
|
||||||
|
context: BuilderContext,
|
||||||
|
command: string[],
|
||||||
|
env: Record<string, any> = {}
|
||||||
|
) {
|
||||||
let project: JsonObject;
|
let project: JsonObject;
|
||||||
if (context.target) {
|
if (context.target) {
|
||||||
project = await context.getProjectMetadata(context.target.project);
|
project = await context.getProjectMetadata(context.target.project);
|
||||||
@ -92,6 +96,10 @@ async function executeCommand(context: BuilderContext, command: string[]) {
|
|||||||
cwd: path,
|
cwd: path,
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
shell: true,
|
shell: true,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
...env,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on('error', message => {
|
child.on('error', message => {
|
||||||
@ -166,10 +174,13 @@ async function executeE2ETest(
|
|||||||
await executeCommand(context, [`tsc`, '-p', 'e2e/tsconfig.json']);
|
await executeCommand(context, [`tsc`, '-p', 'e2e/tsconfig.json']);
|
||||||
|
|
||||||
server = await startServer(options, context);
|
server = await startServer(options, context);
|
||||||
|
const result = await server.result;
|
||||||
|
|
||||||
message('\n Running tests 🧪 ... \n', context);
|
message('\n Running tests 🧪 ... \n', context);
|
||||||
const testRunnerCommand = getCommandForRunner(options.testRunner);
|
const testRunnerCommand = getCommandForRunner(options.testRunner);
|
||||||
await executeCommand(context, testRunnerCommand);
|
await executeCommand(context, testRunnerCommand, {
|
||||||
|
baseUrl: result['baseUrl'],
|
||||||
|
});
|
||||||
|
|
||||||
message('\n 🚀 Test ran successfully! 🚀 ', context, 'success');
|
message('\n 🚀 Test ran successfully! 🚀 ', context, 'success');
|
||||||
return {success: true};
|
return {success: true};
|
||||||
|
@ -3,7 +3,7 @@ import {before, beforeEach, after, afterEach} from 'node:test';
|
|||||||
<% } %>
|
<% } %>
|
||||||
import * as puppeteer from 'puppeteer';
|
import * as puppeteer from 'puppeteer';
|
||||||
|
|
||||||
const baseUrl = '<%= baseUrl %>';
|
const baseUrl = process.env['baseUrl'] ?? '<%= baseUrl %>';
|
||||||
let browser: puppeteer.Browser;
|
let browser: puppeteer.Browser;
|
||||||
let page: puppeteer.Page;
|
let page: puppeteer.Page;
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ async function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (isShell) {
|
if (isShell) {
|
||||||
await runNgSchematicsSandbox(getOptions()).catch(error => {
|
await runNgSchematicsSandbox(options).catch(error => {
|
||||||
console.log('Something went wrong');
|
console.log('Something went wrong');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user