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