chore: fix issue with build files (#10754)
This commit is contained in:
parent
72a10faa5e
commit
c794abc8f6
@ -25,7 +25,7 @@ const terminalStyles = {
|
|||||||
export function getCommandForRunner(runner: TestRunner): [string, ...string[]] {
|
export function getCommandForRunner(runner: TestRunner): [string, ...string[]] {
|
||||||
switch (runner) {
|
switch (runner) {
|
||||||
case TestRunner.Jasmine:
|
case TestRunner.Jasmine:
|
||||||
return [`jasmine`, '--config=./e2e/support/jasmine.json'];
|
return [`jasmine`, '--config=./e2e/jasmine.json'];
|
||||||
case TestRunner.Jest:
|
case TestRunner.Jest:
|
||||||
return [`jest`, '-c', 'e2e/jest.config.js'];
|
return [`jest`, '-c', 'e2e/jest.config.js'];
|
||||||
case TestRunner.Mocha:
|
case TestRunner.Mocha:
|
||||||
@ -37,28 +37,27 @@ export function getCommandForRunner(runner: TestRunner): [string, ...string[]] {
|
|||||||
throw new Error(`Unknown test runner ${runner}!`);
|
throw new Error(`Unknown test runner ${runner}!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getError(executable: string, args: string[]) {
|
|
||||||
return (
|
|
||||||
`Error running '${executable}' with arguments '${args.join(' ')}'.` +
|
|
||||||
`\n` +
|
|
||||||
'Please look at the output above to determine the issue!'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getExecutable(command: string[]) {
|
function getExecutable(command: string[]) {
|
||||||
const executable = command.shift()!;
|
const executable = command.shift()!;
|
||||||
const error = getError(executable, command);
|
const debugError = `Error running '${executable}' with arguments '${command.join(
|
||||||
|
' '
|
||||||
|
)}'.`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
executable,
|
executable,
|
||||||
args: command,
|
args: command,
|
||||||
error,
|
debugError,
|
||||||
|
error: 'Please look at the output above to determine the issue!',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateExecutablePath(command: string, root?: string) {
|
function updateExecutablePath(command: string, root?: string) {
|
||||||
|
if (command === TestRunner.Node) {
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
let path = 'node_modules/.bin/';
|
let path = 'node_modules/.bin/';
|
||||||
if (root && root !== '' && command === TestRunner.Node) {
|
if (root && root !== '') {
|
||||||
const nested = root
|
const nested = root
|
||||||
.split('/')
|
.split('/')
|
||||||
.map(() => {
|
.map(() => {
|
||||||
@ -82,7 +81,7 @@ async function executeCommand(context: BuilderContext, command: string[]) {
|
|||||||
|
|
||||||
await new Promise(async (resolve, reject) => {
|
await new Promise(async (resolve, reject) => {
|
||||||
context.logger.debug(`Trying to execute command - ${command.join(' ')}.`);
|
context.logger.debug(`Trying to execute command - ${command.join(' ')}.`);
|
||||||
const {executable, args, error} = getExecutable(command);
|
const {executable, args, debugError, error} = getExecutable(command);
|
||||||
let path = context.workspaceRoot;
|
let path = context.workspaceRoot;
|
||||||
if (context.target) {
|
if (context.target) {
|
||||||
path = `${path}/${project['root']}`;
|
path = `${path}/${project['root']}`;
|
||||||
@ -94,6 +93,7 @@ async function executeCommand(context: BuilderContext, command: string[]) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
child.on('error', message => {
|
child.on('error', message => {
|
||||||
|
context.logger.debug(debugError);
|
||||||
console.log(message);
|
console.log(message);
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
@ -160,11 +160,11 @@ async function executeE2ETest(
|
|||||||
): Promise<BuilderOutput> {
|
): Promise<BuilderOutput> {
|
||||||
let server: BuilderRun | null = null;
|
let server: BuilderRun | null = null;
|
||||||
try {
|
try {
|
||||||
server = await startServer(options, context);
|
|
||||||
|
|
||||||
message('\n Building tests 🛠️ ... \n', context);
|
message('\n Building tests 🛠️ ... \n', context);
|
||||||
await executeCommand(context, [`tsc`, '-p', 'e2e/tsconfig.json']);
|
await executeCommand(context, [`tsc`, '-p', 'e2e/tsconfig.json']);
|
||||||
|
|
||||||
|
server = await startServer(options, context);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
/** @type {import('jest').Config} */
|
/** @type {import('jest').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
testMatch: ['<rootDir>/tests/**/?(*.)+(e2e).js?(x)'],
|
testMatch: ['<rootDir>/build/**/?(*.)+(e2e).js?(x)'],
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
spec: './e2e/tests/**/*.e2e.js',
|
spec: './e2e/build/**/*.e2e.js',
|
||||||
};
|
};
|
||||||
|
@ -52,7 +52,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
|
|||||||
const {devDependencies} = getPackageJson(tree);
|
const {devDependencies} = getPackageJson(tree);
|
||||||
const {options} = getAngularJsonScripts(tree);
|
const {options} = getAngularJsonScripts(tree);
|
||||||
|
|
||||||
expect(tree.files).toContain('/e2e/support/jasmine.json');
|
expect(tree.files).toContain('/e2e/jasmine.json');
|
||||||
expect(devDependencies).toContain('jasmine');
|
expect(devDependencies).toContain('jasmine');
|
||||||
expect(options['testRunner']).toBe('jasmine');
|
expect(options['testRunner']).toBe('jasmine');
|
||||||
});
|
});
|
||||||
@ -140,9 +140,7 @@ describe('@puppeteer/ng-schematics: ng-add', () => {
|
|||||||
const {devDependencies} = getPackageJson(tree);
|
const {devDependencies} = getPackageJson(tree);
|
||||||
const {options} = getAngularJsonScripts(tree);
|
const {options} = getAngularJsonScripts(tree);
|
||||||
|
|
||||||
expect(tree.files).toContain(
|
expect(tree.files).toContain(getMultiProjectFile('e2e/jasmine.json'));
|
||||||
getMultiProjectFile('e2e/support/jasmine.json')
|
|
||||||
);
|
|
||||||
expect(devDependencies).toContain('jasmine');
|
expect(devDependencies).toContain('jasmine');
|
||||||
expect(options['testRunner']).toBe('jasmine');
|
expect(options['testRunner']).toBe('jasmine');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user