|
| 1 | +import { |
| 2 | + checkFilesExist, |
| 3 | + ensureNxProject, |
| 4 | + readJson, |
| 5 | + runNxCommandAsync, |
| 6 | + uniq, |
| 7 | +} from '@nrwl/nx-plugin/testing'; |
| 8 | + |
| 9 | +describe('nx-plugin e2e', () => { |
| 10 | + // Setting up individual workspaces per |
| 11 | + // test can cause e2e runs to take a long time. |
| 12 | + // For this reason, we recommend each suite only |
| 13 | + // consumes 1 workspace. The tests should each operate |
| 14 | + // on a unique project in the workspace, such that they |
| 15 | + // are not dependent on one another. |
| 16 | + beforeAll(() => { |
| 17 | + ensureNxProject('@analogjs/nx', 'dist/packages/nx-plugin'); |
| 18 | + }); |
| 19 | + |
| 20 | + afterAll(() => { |
| 21 | + // `nx reset` kills the daemon, and performs |
| 22 | + // some work which can help clean up e2e leftovers |
| 23 | + runNxCommandAsync('reset'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should create hello-world', async () => { |
| 27 | + const project = uniq('hello-world'); |
| 28 | + await runNxCommandAsync(`generate @analogjs/nx:app ${project}`); |
| 29 | + const result = await runNxCommandAsync(`build ${project}`); |
| 30 | + expect(result.stdout).toContain( |
| 31 | + 'Successfully ran target build for project' |
| 32 | + ); |
| 33 | + }, 120000); |
| 34 | + |
| 35 | + describe('--directory', () => { |
| 36 | + it('should create src in the specified directory', async () => { |
| 37 | + const project = uniq('hello-world'); |
| 38 | + await runNxCommandAsync( |
| 39 | + `generate @analogjs/nx:app ${project} --directory subdir` |
| 40 | + ); |
| 41 | + expect(() => |
| 42 | + checkFilesExist(`apps/subdir/${project}/index.html`) |
| 43 | + ).not.toThrow(); |
| 44 | + }, 120000); |
| 45 | + }); |
| 46 | + |
| 47 | + describe('--tags', () => { |
| 48 | + it('should add tags to the project', async () => { |
| 49 | + const projectName = uniq('hello-world'); |
| 50 | + await runNxCommandAsync( |
| 51 | + `generate @analogjs/nx:app ${projectName} --tags e2etag,e2ePackage` |
| 52 | + ); |
| 53 | + const project = readJson(`apps/${projectName}/project.json`); |
| 54 | + expect(project.tags).toEqual(['e2etag', 'e2ePackage']); |
| 55 | + }, 120000); |
| 56 | + }); |
| 57 | +}); |
0 commit comments