Skip to content

Commit bfe75d7

Browse files
chore: setup e2e (#62)
1 parent bf0e2e2 commit bfe75d7

File tree

10 files changed

+1118
-37
lines changed

10 files changed

+1118
-37
lines changed

.github/actions/test/action.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ runs:
2222
shell: bash
2323
run: npx nx affected --target=test --base=last-release
2424

25-
# - name: E2E Tests
26-
# shell: bash
27-
# run: npx nx affected --target=e2e --base=last-release
25+
- name: E2E Tests
26+
shell: bash
27+
run: npx nx affected --target=e2e --base=last-release
2828

2929
# - name: Codecov upload
3030
# uses: codecov/codecov-action@v2

.npmrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
save-exact = true
1+
save-exact=true
2+
auto-install-peers=true

e2e/qwik-nx-e2e/tests/qwik-nx.spec.ts

+36-24
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import {
22
checkFilesExist,
33
ensureNxProject,
4-
readJson,
54
runNxCommandAsync,
65
uniq,
76
} from '@nrwl/nx-plugin/testing';
87

8+
import {
9+
runCommandUntil,
10+
promisifiedTreeKill,
11+
killPort,
12+
} from '@qwikifiers/e2e/utils';
13+
914
describe('qwik-nx e2e', () => {
1015
// Setting up individual workspaces per
1116
// test can cause e2e runs to take a long time.
@@ -23,34 +28,41 @@ describe('qwik-nx e2e', () => {
2328
runNxCommandAsync('reset');
2429
});
2530

26-
it('should create qwik-nx', async () => {
27-
const project = uniq('qwik-nx');
28-
await runNxCommandAsync(`generate qwik-nx:app ${project}`);
29-
const result = await runNxCommandAsync(`build ${project}`);
30-
expect(result.stdout).toContain('Executor ran');
31-
}, 120000);
32-
33-
describe('--directory', () => {
34-
it('should create src in the specified directory', async () => {
35-
const project = uniq('qwik-nx');
31+
describe('Basic behavior', () => {
32+
let project: string;
33+
beforeAll(async () => {
34+
project = uniq('qwik-nx');
3635
await runNxCommandAsync(
37-
`generate qwik-nx:app ${project} --directory subdir`
36+
`generate qwik-nx:app ${project} --no-interactive`
37+
);
38+
}, 200000);
39+
it('should create qwik-nx', async () => {
40+
const result = await runNxCommandAsync(`build-ssr ${project}`);
41+
expect(result.stdout).toContain(
42+
`Successfully ran target build-ssr for project ${project}`
3843
);
3944
expect(() =>
40-
checkFilesExist(`libs/subdir/${project}/src/index.ts`)
45+
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
4146
).not.toThrow();
42-
}, 120000);
43-
});
47+
expect(() =>
48+
checkFilesExist(`dist/apps/${project}/server/entry.preview.mjs`)
49+
).not.toThrow();
50+
}, 200000);
4451

45-
describe('--tags', () => {
46-
it('should add tags to the project', async () => {
47-
const projectName = uniq('qwik-nx');
48-
ensureNxProject('qwik-nx', 'dist/packages/qwik-nx');
49-
await runNxCommandAsync(
50-
`generate qwik-nx:app ${projectName} --tags e2etag,e2ePackage`
52+
it('should serve application in dev mode with custom port', async () => {
53+
const port = 4212;
54+
const p = await runCommandUntil(
55+
`run ${project}:serve --port=${port}`,
56+
(output) => {
57+
return output.includes('Local:') && output.includes(`:${port}`);
58+
}
5159
);
52-
const project = readJson(`libs/${projectName}/project.json`);
53-
expect(project.tags).toEqual(['e2etag', 'e2ePackage']);
54-
}, 120000);
60+
try {
61+
await promisifiedTreeKill(p.pid, 'SIGKILL');
62+
await killPort(port);
63+
} catch {
64+
// ignore
65+
}
66+
}, 200000);
5567
});
5668
});

0 commit comments

Comments
 (0)