From 074479abc5027b3d67cc6946708e80163fbcecd1 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Wed, 11 Dec 2024 14:34:00 -0500 Subject: [PATCH] chore(repo): update e2e tests --- e2e/node/src/node-esbuild.test.ts | 2 +- e2e/node/src/node-server.test.ts | 22 ++++++----- e2e/node/src/node-webpack.test.ts | 2 +- e2e/node/src/node.test.ts | 66 +++++++++++++++++++++---------- e2e/nuxt/src/nuxt.test.ts | 2 +- 5 files changed, 62 insertions(+), 32 deletions(-) diff --git a/e2e/node/src/node-esbuild.test.ts b/e2e/node/src/node-esbuild.test.ts index e3531b48dcf4a..5b9da308d0bf5 100644 --- a/e2e/node/src/node-esbuild.test.ts +++ b/e2e/node/src/node-esbuild.test.ts @@ -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`); diff --git a/e2e/node/src/node-server.test.ts b/e2e/node/src/node-server.test.ts index cf5361fdebb8c..dff425656334a 100644 --- a/e2e/node/src/node-server.test.ts +++ b/e2e/node/src/node-server.test.ts @@ -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); @@ -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`); @@ -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`]; diff --git a/e2e/node/src/node-webpack.test.ts b/e2e/node/src/node-webpack.test.ts index f38b87f752f66..2d98ee18ea71d 100644 --- a/e2e/node/src/node-webpack.test.ts +++ b/e2e/node/src/node-webpack.test.ts @@ -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' }, } diff --git a/e2e/node/src/node.test.ts b/e2e/node/src/node.test.ts index e5955ac93ec9b..a0495612c602f 100644 --- a/e2e/node/src/node.test.ts +++ b/e2e/node/src/node.test.ts @@ -72,7 +72,7 @@ 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}`); @@ -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'; @@ -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}`); @@ -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"`); @@ -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(); @@ -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}`); @@ -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'); @@ -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`); @@ -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'; @@ -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`); @@ -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`); @@ -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 @@ -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 @@ -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 @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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'); diff --git a/e2e/nuxt/src/nuxt.test.ts b/e2e/nuxt/src/nuxt.test.ts index 88ad5973d8473..0cffcddbfd0a5 100644 --- a/e2e/nuxt/src/nuxt.test.ts +++ b/e2e/nuxt/src/nuxt.test.ts @@ -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=eslitn` ); runCLI( `generate @nx/nuxt:component ${app}/src/components/one/one --name=one --unitTestRunner=vitest`