Skip to content

Commit

Permalink
chore(repo): update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Dec 12, 2024
1 parent ab6dde1 commit 514d742
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 40 deletions.
2 changes: 1 addition & 1 deletion e2e/eslint/src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ describe('Linter', () => {
const mylib = uniq('mylib');

runCLI(
`generate @nx/react:app --name=${myapp} --unitTestRunner=jest --linter eslint --directory="."`
`generate @nx/react:app --name=${myapp} --unitTestRunner=jest --linter eslint --e2eTestRunner=jest --directory="."`
);
runCLI('reset', { env: { CI: 'false' } });
verifySuccessfulStandaloneSetup(myapp);
Expand Down
2 changes: 1 addition & 1 deletion e2e/jest/src/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Jest', () => {
it('should be able to test node lib with babel-jest', async () => {
const libName = uniq('babel-test-lib');
runCLI(
`generate @nx/node:lib libs/${libName} --buildable --importPath=@some-org/babel-test --publishable --babelJest`
`generate @nx/node:lib libs/${libName} --buildable --importPath=@some-org/babel-test --publishable --babelJest --unitTestRunner=jest`
);

const cliResults = await runCLIAsync(`test ${libName}`);
Expand Down
2 changes: 1 addition & 1 deletion e2e/node/src/node-esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Node Applications + esbuild', () => {
const app = uniq('nodeapp');

runCLI(
`generate @nx/node:app apps/${app} --bundler=esbuild --no-interactive`
`generate @nx/node:app apps/${app} --bundler=esbuild --no-interactive --linter=eslint --unitTestRunner=jest`
);

checkFilesDoNotExist(`apps/${app}/webpack.config.js`);
Expand Down
22 changes: 13 additions & 9 deletions e2e/node/src/node-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,23 @@ describe('Node Applications + webpack', () => {
const nestApp = uniq('nest');

beforeAll(() => {
runCLI(`generate @nx/node:lib libs/${testLib1}`);
runCLI(`generate @nx/node:lib libs/${testLib2} --importPath=@acme/test2`);
runCLI(
`generate @nx/node:app apps/${expressApp} --framework=express --port=7000 --no-interactive`
`generate @nx/node:lib libs/${testLib1} --linter=eslint --unitTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${fastifyApp} --framework=fastify --port=7001 --no-interactive`
`generate @nx/node:lib libs/${testLib2} --importPath=@acme/test2 --linter=eslint --unitTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${koaApp} --framework=koa --port=7002 --no-interactive`
`generate @nx/node:app apps/${expressApp} --framework=express --port=7000 --no-interactive --linter=eslint --unitTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${nestApp} --framework=nest --port=7003 --bundler=webpack --no-interactive`
`generate @nx/node:app apps/${fastifyApp} --framework=fastify --port=7001 --no-interactive --linter=eslint --unitTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${koaApp} --framework=koa --port=7002 --no-interactive --linter=eslint --unitTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${nestApp} --framework=nest --port=7003 --bundler=webpack --no-interactive --linter=eslint --unitTestRunner=jest`
);

addLibImport(expressApp, testLib1);
Expand Down Expand Up @@ -165,7 +169,7 @@ describe('Node Applications + webpack', () => {
const expressApp = 'docker-express-app'; // needs to be consistent for the Dockerfile snapshot

runCLI(
`generate @nx/node:app apps/${expressApp} --framework=express --docker --no-interactive`
`generate @nx/node:app apps/${expressApp} --framework=express --docker --no-interactive --linter=eslint --unitTestRunner=jest`
);

checkFilesExist(`apps/${expressApp}/Dockerfile`);
Expand All @@ -179,10 +183,10 @@ describe('Node Applications + webpack', () => {

// Set ports to avoid conflicts with other tests that might run in parallel
runCLI(
`generate @nx/node:app apps/${nodeApp1} --framework=none --no-interactive --port=4444`
`generate @nx/node:app apps/${nodeApp1} --framework=none --no-interactive --port=4444 --linter=eslint --unitTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${nodeApp2} --framework=none --no-interactive --port=4445`
`generate @nx/node:app apps/${nodeApp2} --framework=none --no-interactive --port=4445 --linter=eslint --unitTestRunner=jest`
);
updateJson(join('apps', nodeApp1, 'project.json'), (config) => {
config.targets.serve.options.waitUntilTargets = [`${nodeApp2}:build`];
Expand Down
2 changes: 1 addition & 1 deletion e2e/node/src/node-webpack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Node Applications + webpack', () => {

// This fails with Crystal enabled because `--optimization` is not a correct flag to pass to `webpack`.
runCLI(
`generate @nx/node:app apps/${app} --bundler=webpack --no-interactive`,
`generate @nx/node:app apps/${app} --bundler=webpack --no-interactive --linter=eslint --unitTestRunner=jest`,
{
env: { NX_ADD_PLUGINS: 'false' },
}
Expand Down
74 changes: 48 additions & 26 deletions e2e/node/src/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ describe('Node Applications', () => {
const port = getRandomPort();
process.env.PORT = `${port}`;
runCLI(
`generate @nx/node:app apps/${nodeapp} --port=${port} --linter=eslint`
`generate @nx/node:app apps/${nodeapp} --port=${port} --linter=eslint --unitTestRunner=jest`
);

const lintResults = runCLI(`lint ${nodeapp}`);
expect(lintResults).toContain('Successfully ran target lint');
expect(() => runCLI(`lint ${nodeapp}`)).not.toThrow();
expect(() => runCLI(`test ${nodeapp}`)).not.toThrow();

updateFile(`apps/${nodeapp}/src/main.ts`, `console.log('Hello World!');`);
await runCLIAsync(`build ${nodeapp}`);
Expand All @@ -92,7 +92,9 @@ describe('Node Applications', () => {
// TODO(crystal, @ndcunningham): This does not work because NxWebpackPlugin({}) outputFilename does not work.
xit('should be able to generate the correct outputFileName in options', async () => {
const nodeapp = uniq('nodeapp');
runCLI(`generate @nx/node:app apps/${nodeapp} --linter=eslint`);
runCLI(
`generate @nx/node:app apps/${nodeapp} --linter=eslint --unitTestRunner=jest`
);

updateJson(join('apps', nodeapp, 'project.json'), (config) => {
config.targets.build.options.outputFileName = 'index.js';
Expand All @@ -108,7 +110,7 @@ describe('Node Applications', () => {
const port = getRandomPort();
process.env.PORT = `${port}`;
runCLI(
`generate @nx/node:app apps/${nodeapp} --port=${port} --linter=eslint --bundler=webpack`
`generate @nx/node:app apps/${nodeapp} --port=${port} --linter=eslint --bundler=webpack --unitTestRunner=jest`
);

const lintResults = runCLI(`lint ${nodeapp}`);
Expand Down Expand Up @@ -190,7 +192,7 @@ module.exports = {
const nodeapp = uniq('nodeapp');

runCLI(
`generate @nx/node:app apps/${nodeapp} --linter=eslint --bundler=webpack --framework=none`
`generate @nx/node:app apps/${nodeapp} --linter=eslint --bundler=webpack --framework=none --unitTestRunner=jest`
);

updateFile('.env', `NX_FOOBAR="test foo bar"`);
Expand Down Expand Up @@ -227,7 +229,9 @@ module.exports = {
it("should exclude 'test' target from e2e project that uses jest", async () => {
const appName = uniq('nodeapp');

runCLI(`generate @nx/node:app ${appName} --no-interactive`);
runCLI(
`generate @nx/node:app ${appName} --no-interactive --unitTestRunner=jest --linter=eslint`
);

const nxJson = JSON.parse(readFile('nx.json'));
expect(nxJson.plugins).toBeDefined();
Expand All @@ -246,7 +250,7 @@ module.exports = {
process.env.PORT = `${port}`;

runCLI(
`generate @nx/express:app apps/${nodeapp} --port=${port} --linter=eslint`
`generate @nx/express:app apps/${nodeapp} --port=${port} --linter=eslint --unitTestRunner=jest`
);

const lintResults = runCLI(`lint ${nodeapp}`);
Expand Down Expand Up @@ -296,7 +300,9 @@ module.exports = {
it('should be able to generate a nest application', async () => {
const nestapp = uniq('nestapp');
const port = 3335;
runCLI(`generate @nx/nest:app apps/${nestapp} --linter=eslint`);
runCLI(
`generate @nx/nest:app apps/${nestapp} --linter=eslint --unitTestRunner=jest`
);

const lintResults = runCLI(`lint ${nestapp}`);
expect(lintResults).toContain('Successfully ran target lint');
Expand Down Expand Up @@ -344,7 +350,7 @@ module.exports = {
const nestapp = 'node-nest-docker-test';

runCLI(
`generate @nx/node:app ${nestapp} --bundler=webpack --framework=nest --docker`
`generate @nx/node:app ${nestapp} --bundler=webpack --framework=nest --docker --unitTestRunner=jest`
);

checkFilesExist(`${nestapp}/Dockerfile`);
Expand All @@ -359,7 +365,7 @@ module.exports = {
const esmapp = uniq('esmapp');

runCLI(
`generate @nx/node:app ${esmapp} --linter=eslint --framework=none --bundler=webpack`
`generate @nx/node:app ${esmapp} --linter=eslint --framework=none --bundler=webpack --unitTestRunner=jest`
);
updateJson(`apps/${esmapp}/tsconfig.app.json`, (config) => {
config.module = 'esnext';
Expand Down Expand Up @@ -424,7 +430,9 @@ describe('Build Node apps', () => {
xit('should generate a package.json with the `--generatePackageJson` flag', async () => {
const packageManager = detectPackageManager(tmpProjPath());
const nestapp = uniq('nestapp');
runCLI(`generate @nx/nest:app apps/${nestapp} --linter=eslint`);
runCLI(
`generate @nx/nest:app apps/${nestapp} --linter=eslint --unitTestRunner=jest`
);

await runCLIAsync(`build ${nestapp} --generatePackageJson`);

Expand Down Expand Up @@ -485,7 +493,9 @@ describe('Build Node apps', () => {
});

const nodeapp = uniq('nodeapp');
runCLI(`generate @nx/node:app ${nodeapp} --bundler=webpack`);
runCLI(
`generate @nx/node:app ${nodeapp} --bundler=webpack --unitTestRunner=jest --linter=eslint`
);

const jslib = uniq('jslib');
runCLI(`generate @nx/js:lib ${jslib} --bundler=tsc`);
Expand Down Expand Up @@ -529,7 +539,7 @@ ${jslib}();
process.env.PORT = `${port}`;

runCLI(
`generate @nx/node:app apps/${appName} --port=${port} --no-interactive`
`generate @nx/node:app apps/${appName} --port=${port} --no-interactive --linter=eslint --unitTestRunner=jest`
);

// deleteOutputPath should default to true
Expand Down Expand Up @@ -569,7 +579,9 @@ ${jslib}();
const port = getRandomPort();
process.env.PORT = `${port}`;

runCLI(`generate @nx/node:app ${appName} --port=${port} --no-interactive`);
runCLI(
`generate @nx/node:app ${appName} --port=${port} --no-interactive --linter=eslint --unitTestRunner=jest`
);

// check files are generated without the layout directory ("apps/") and
// using the project name as the directory when no directory is provided
Expand All @@ -584,7 +596,9 @@ ${jslib}();
`Successfully ran target test for project ${appName}`
);

runCLI(`generate @nx/node:lib ${libName} --buildable --no-interactive`);
runCLI(
`generate @nx/node:lib ${libName} --buildable --no-interactive --linter=eslint --unitTestRunner=jest`
);

// check files are generated without the layout directory ("libs/") and
// using the project name as the directory when no directory is provided
Expand All @@ -605,7 +619,9 @@ ${jslib}();
// TODO(crystal, @ndcunningham): What is the alternative here?
xit('should have plugin output if specified in `tsPlugins`', async () => {
const nestapp = uniq('nestapp');
runCLI(`generate @nx/nest:app ${nestapp} --linter=eslint`);
runCLI(
`generate @nx/nest:app ${nestapp} --linter=eslint --unitTestRunner=jest`
);

packageInstall('@nestjs/swagger', undefined, '^7.0.0');

Expand Down Expand Up @@ -659,7 +675,9 @@ ${jslib}();
describe('nest libraries', function () {
it('should be able to generate a nest library', async () => {
const nestlib = uniq('nestlib');
runCLI(`generate @nx/nest:lib libs/${nestlib}`);
runCLI(
`generate @nx/nest:lib libs/${nestlib} --linter=eslint --unitTestRunner=jest`
);

const lintResults = runCLI(`lint ${nestlib}`);
expect(lintResults).toContain('Successfully ran target lint');
Expand All @@ -673,7 +691,9 @@ ${jslib}();
it('should be able to generate a nest library w/ service', async () => {
const nestlib = uniq('nestlib');

runCLI(`generate @nx/nest:lib ${nestlib} --service`);
runCLI(
`generate @nx/nest:lib ${nestlib} --service --linter=eslint --unitTestRunner=jest`
);

const lintResults = runCLI(`lint ${nestlib}`);
expect(lintResults).toContain('Successfully ran target lint');
Expand All @@ -687,7 +707,9 @@ ${jslib}();
it('should be able to generate a nest library w/ controller', async () => {
const nestlib = uniq('nestlib');

runCLI(`generate @nx/nest:lib ${nestlib} --controller`);
runCLI(
`generate @nx/nest:lib ${nestlib} --controller --linter=eslint --unitTestRunner=jest`
);

const lintResults = runCLI(`lint ${nestlib}`);
expect(lintResults).toContain('Successfully ran target lint');
Expand All @@ -701,7 +723,9 @@ ${jslib}();
it('should be able to generate a nest library w/ controller and service', async () => {
const nestlib = uniq('nestlib');

runCLI(`generate @nx/nest:lib ${nestlib} --controller --service`);
runCLI(
`generate @nx/nest:lib ${nestlib} --controller --service --linter=eslint --unitTestRunner=jest`
);

const lintResults = runCLI(`lint ${nestlib}`);
expect(lintResults).toContain('Successfully ran target lint');
Expand All @@ -714,7 +738,9 @@ ${jslib}();

it('should have plugin output if specified in `transformers`', async () => {
const nestlib = uniq('nestlib');
runCLI(`generate @nx/nest:lib libs/${nestlib} --buildable`);
runCLI(
`generate @nx/nest:lib libs/${nestlib} --buildable --linter=eslint --unitTestRunner=jest`
);

packageInstall('@nestjs/swagger', undefined, '^7.0.0');

Expand Down Expand Up @@ -758,9 +784,5 @@ exports.FooModel = FooModel;
`
);
}, 300000);

it('should run default jest tests', async () => {
await expectJestTestsToPass('@nx/node:lib');
}, 100000);
});
});
2 changes: 1 addition & 1 deletion e2e/nuxt/src/nuxt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Nuxt Plugin', () => {
packages: ['@nx/nuxt'],
});
runCLI(
`generate @nx/nuxt:app ${app} --unitTestRunner=vitest --e2eTestRunner=cypress`
`generate @nx/nuxt:app ${app} --unitTestRunner=vitest --e2eTestRunner=cypress --linter=eslint`
);
runCLI(
`generate @nx/nuxt:component ${app}/src/components/one/one --name=one --unitTestRunner=vitest`
Expand Down

0 comments on commit 514d742

Please sign in to comment.