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