fix(node): quote filepath in cli e2e sample test (#14779)

Fixes https://github.com/nrwl/nx/issues/14761
This commit is contained in:
Caleb Ukle 2023-02-02 11:02:06 -06:00 committed by GitHub
parent 259d4b29cf
commit bc788ff876
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -38,4 +38,33 @@ describe('e2eProjectGenerator', () => {
expect(tree.exists(`e2e/src/server/server.spec.ts`)).toBeTruthy(); expect(tree.exists(`e2e/src/server/server.spec.ts`)).toBeTruthy();
}); });
it('should generate cli project', async () => {
await applicationGenerator(tree, {
name: 'api',
framework: 'none',
e2eTestRunner: 'none',
});
await e2eProjectGenerator(tree, {
projectType: 'cli',
project: 'api',
});
expect(tree.read('api-e2e/src/api/api.spec.ts', 'utf-8'))
.toMatchInlineSnapshot(`
"import { execSync } from 'child_process';
import { join } from 'path';
describe('CLI tests', () => {
it('should print a message', () => {
const cliPath = join(process.cwd(), \\"dist/api\\");
const output = execSync(\`node \${cliPath}\`).toString();
expect(output).toMatch(/Hello World/);
});
});
"
`);
});
}); });

View File

@ -3,7 +3,7 @@ import { join } from 'path';
describe('CLI tests', () => { describe('CLI tests', () => {
it('should print a message', () => { it('should print a message', () => {
const cliPath = join(process.cwd(), <%= mainFile %>); const cliPath = join(process.cwd(), "<%= mainFile %>");
const output = execSync(`node ${cliPath}`).toString(); const output = execSync(`node ${cliPath}`).toString();