cleanup(misc): add packages option to e2e newProject function (#20713)

This commit is contained in:
Katerina Skroumpelou 2023-12-12 16:05:41 +02:00 committed by GitHub
parent 5b4305819b
commit 7c1645e8e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 31 deletions

View File

@ -13,6 +13,7 @@ describe('Nuxt Plugin', () => {
beforeAll(() => {
proj = newProject({
packages: ['@nx/nuxt', '@nx/storybook'],
unsetProjectNameAndRootFormat: false,
});
runCLI(`generate @nx/nuxt:app ${app} --unitTestRunner=vitest`);

View File

@ -17,7 +17,9 @@ describe('Storybook generators and executors for monorepos', () => {
const reactStorybookApp = uniq('react-app');
let proj;
beforeAll(async () => {
proj = newProject();
proj = newProject({
packages: ['@nx/react', '@nx/storybook'],
});
runCLI(
`generate @nx/react:app ${reactStorybookApp} --bundler=webpack --project-name-and-root-format=as-provided --no-interactive`
);

View File

@ -11,7 +11,12 @@ import {
// This test ensures that when CJS is gone from the published `vite` package, Nx will continue to work.
describe('Vite ESM tests', () => {
beforeAll(() => newProject({ unsetProjectNameAndRootFormat: false }));
beforeAll(() =>
newProject({
unsetProjectNameAndRootFormat: false,
packages: ['@nx/react'],
})
);
it('should build with Vite when it is ESM-only', async () => {
const appName = uniq('viteapp');

View File

@ -1,6 +1,7 @@
import { cleanupProject, newProject, runCLI, uniq } from '@nx/e2e/utils';
const myApp = uniq('my-app');
const myVueApp = uniq('my-vue-app');
describe('@nx/vite/plugin', () => {
let proj: string;
@ -9,43 +10,21 @@ describe('@nx/vite/plugin', () => {
beforeAll(() => {
originalEnv = process.env.NX_PCV3;
process.env.NX_PCV3 = 'true';
proj = newProject({
packages: ['@nx/react', '@nx/vue'],
});
runCLI(
`generate @nx/react:app ${myApp} --bundler=vite --unitTestRunner=vitest`
);
runCLI(`generate @nx/vue:app ${myVueApp} --unitTestRunner=vitest`);
});
afterAll(() => {
process.env.NODE_ENV = originalEnv;
});
describe('build and test React Vite app', () => {
beforeAll(() => {
proj = newProject();
runCLI(
`generate @nx/react:app ${myApp} --bundler=vite --unitTestRunner=vitest`
);
});
afterAll(() => cleanupProject());
it('should build application', () => {
const result = runCLI(`build ${myApp}`);
expect(result).toContain('Successfully ran target build');
}, 200_000);
it('should test application', () => {
const result = runCLI(`test ${myApp}`);
expect(result).toContain('Successfully ran target test');
}, 200_000);
});
describe('build and test Vue app', () => {
beforeAll(() => {
proj = newProject();
runCLI(`generate @nx/vue:app ${myApp} --unitTestRunner=vitest`);
});
afterAll(() => {
cleanupProject();
});
describe('build and test React app', () => {
it('should build application', () => {
const result = runCLI(`build ${myApp}`);
expect(result).toContain('Successfully ran target build');
@ -56,4 +35,15 @@ describe('@nx/vite/plugin', () => {
expect(result).toContain('Successfully ran target test');
}, 200_000);
});
describe('build and test Vue app', () => {
it('should build application', () => {
const result = runCLI(`build ${myVueApp}`);
expect(result).toContain('Successfully ran target build');
}, 200_000);
it('should test application', () => {
const result = runCLI(`test ${myVueApp}`);
expect(result).toContain('Successfully ran target test');
}, 200_000);
});
});

View File

@ -31,7 +31,9 @@ describe('Vite Plugin', () => {
describe('Vite on React apps', () => {
describe('set up new React app with --bundler=vite option', () => {
beforeEach(async () => {
proj = newProject();
proj = newProject({
packages: ['@nx/react'],
});
runCLI(`generate @nx/react:app ${myApp} --bundler=vite`);
createFile(`apps/${myApp}/public/hello.md`, `# Hello World`);
});
@ -49,7 +51,9 @@ describe('Vite Plugin', () => {
describe('Vite on Web apps', () => {
describe('set up new @nx/web app with --bundler=vite option', () => {
beforeEach(() => {
proj = newProject();
proj = newProject({
packages: ['@nx/web'],
});
runCLI(`generate @nx/web:app ${myApp} --bundler=vite`);
});
afterEach(() => cleanupProject());
@ -122,7 +126,10 @@ describe('Vite Plugin', () => {
const app = uniq('demo');
const lib = uniq('my-lib');
beforeAll(() => {
proj = newProject({ name: uniq('vite-incr-build') });
proj = newProject({
name: uniq('vite-incr-build'),
packages: ['@nx/react'],
});
runCLI(`generate @nx/react:app ${app} --bundler=vite --no-interactive`);
// only this project will be directly used from dist
@ -206,7 +213,7 @@ export default App;
describe('should be able to create libs that use vitest', () => {
const lib = uniq('my-lib');
beforeEach(() => {
proj = newProject({ name: uniq('vite-proj') });
proj = newProject({ name: uniq('vite-proj'), packages: ['@nx/react'] });
});
it('should be able to run tests', async () => {
@ -359,7 +366,10 @@ export default defineConfig({
describe('ESM-only apps', () => {
beforeAll(() => {
newProject({ unsetProjectNameAndRootFormat: false });
newProject({
unsetProjectNameAndRootFormat: false,
packages: ['@nx/react'],
});
});
it('should support ESM-only plugins in vite.config.ts for root apps (#NXP-168)', () => {

View File

@ -12,7 +12,9 @@ describe('Storybook generators and executors for Vue projects', () => {
const vueStorybookApp = uniq('vue-app');
let proj;
beforeAll(async () => {
proj = newProject();
proj = newProject({
packages: ['@nx/vue', '@nx/storybook'],
});
runCLI(
`generate @nx/vue:app ${vueStorybookApp} --project-name-and-root-format=as-provided --no-interactive`
);

View File

@ -10,7 +10,7 @@ import {
describe('vue tailwind support', () => {
beforeAll(() => {
newProject({ unsetProjectNameAndRootFormat: false });
newProject({ unsetProjectNameAndRootFormat: false, packages: ['@nx/vue'] });
});
afterAll(() => {

View File

@ -12,6 +12,7 @@ describe('Vue Plugin', () => {
beforeAll(() => {
proj = newProject({
packages: ['@nx/vue'],
unsetProjectNameAndRootFormat: false,
});
});