fix(core): support --only-failed option with run-many command (#3054)
This commit is contained in:
parent
c2b8c22555
commit
6e79f255a0
@ -138,6 +138,60 @@ forEachCli((cliName) => {
|
|||||||
expect(buildConfig).toContain(`run ${libA}:build:production`);
|
expect(buildConfig).toContain(`run ${libA}:build:production`);
|
||||||
expect(buildConfig).toContain('Running target "build" succeeded');
|
expect(buildConfig).toContain('Running target "build" succeeded');
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
|
|
||||||
|
it('should run only failed projects', () => {
|
||||||
|
ensureProject();
|
||||||
|
const myapp = uniq('myapp');
|
||||||
|
const myapp2 = uniq('myapp2');
|
||||||
|
runCLI(`generate @nrwl/angular:app ${myapp}`);
|
||||||
|
runCLI(`generate @nrwl/angular:app ${myapp2}`);
|
||||||
|
|
||||||
|
// set broken test for myapp
|
||||||
|
updateFile(
|
||||||
|
`apps/${myapp}/src/app/app.component.spec.ts`,
|
||||||
|
`
|
||||||
|
describe('sample test', () => {
|
||||||
|
it('should test', () => {
|
||||||
|
expect(1).toEqual(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
const failedTests = runCLI(`run-many --target=test --all`, {
|
||||||
|
silenceError: true,
|
||||||
|
});
|
||||||
|
expect(failedTests).toContain(`Running target test for projects:`);
|
||||||
|
expect(failedTests).toContain(`- ${myapp}`);
|
||||||
|
expect(failedTests).toContain(`- ${myapp2}`);
|
||||||
|
expect(failedTests).toContain(`Failed projects:`);
|
||||||
|
expect(readJson('dist/.nx-results')).toEqual({
|
||||||
|
command: 'test',
|
||||||
|
results: {
|
||||||
|
[myapp]: false,
|
||||||
|
[myapp2]: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fix failing Unit Test
|
||||||
|
updateFile(
|
||||||
|
`apps/${myapp}/src/app/app.component.spec.ts`,
|
||||||
|
readFile(`apps/${myapp}/src/app/app.component.spec.ts`).replace(
|
||||||
|
'.toEqual(2)',
|
||||||
|
'.toEqual(1)'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const isolatedTests = runCLI(
|
||||||
|
`run-many --target=test --all --only-failed`
|
||||||
|
);
|
||||||
|
expect(isolatedTests).toContain(`Running target test for projects`);
|
||||||
|
expect(isolatedTests).toContain(`- ${myapp}`);
|
||||||
|
expect(isolatedTests).not.toContain(`- ${myapp2}`);
|
||||||
|
|
||||||
|
const interpolatedTests = runCLI(`run-many --target=test --all`);
|
||||||
|
expect(interpolatedTests).toContain(`Running target \"test\" succeeded`);
|
||||||
|
}, 1000000);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('affected:*', () => {
|
describe('affected:*', () => {
|
||||||
|
|||||||
@ -26,8 +26,11 @@ export function runMany(parsedArgs: yargs.Arguments): void {
|
|||||||
projectMap[proj.name] = proj;
|
projectMap[proj.name] = proj;
|
||||||
});
|
});
|
||||||
const env = readEnvironment(nxArgs.target, projectMap);
|
const env = readEnvironment(nxArgs.target, projectMap);
|
||||||
|
const filteredProjects = Object.values(projects).filter(
|
||||||
|
(n) => !parsedArgs.onlyFailed || !env.workspaceResults.getResult(n.name)
|
||||||
|
);
|
||||||
runCommand(
|
runCommand(
|
||||||
projects,
|
filteredProjects,
|
||||||
projectGraph,
|
projectGraph,
|
||||||
env,
|
env,
|
||||||
nxArgs,
|
nxArgs,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user