Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,28 @@ jobs:
run: npm run nx -- run-many -t build --skip-nx-cache --parallel=false
- name: test
run: npm run nx -- run-many -t test --skip-nx-cache --parallel=false

e2e:
runs-on: ubuntu-latest
# a hung local registry or workspace scaffold must not burn the 6h default
timeout-minutes: 20
strategy:
matrix:
node-version: [22.x]
name: E2E Node ${{ matrix.node-version }}

steps:
- uses: actions/checkout@v4
# `nx release version` resolves the current version from git tags
with:
fetch-depth: 0
- name: Setup node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: ${{ matrix.node-version }}
- name: install
run: npm ci
- name: e2e
# stream, because nx buffers task output and a hang would otherwise log nothing
run: npm run nx -- run-many -t e2e --skip-nx-cache --parallel=false --output-style=stream
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/out-tsc

# dependencies
/node_modules
node_modules/

# IDEs and editors
/.idea
Expand Down
2 changes: 2 additions & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# the e2e installs this frozen scaffold into a temp dir; it is not a project here
e2e/nx-plugin-e2e/fixtures
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
/coverage

/.nx/cache
/.nx/workspace-data
/.nx/workspace-data
/e2e/nx-plugin-e2e/fixtures
6 changes: 3 additions & 3 deletions e2e/cli-e2e/tests/collect/config.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect } from 'vitest';
import { CliTest, DEFAULT_RC, USER_FLOW_MOCKS } from '../../utils/setup';
import { CliTest, DEFAULT_RC, stripNodeWarnings, USER_FLOW_MOCKS } from '../../utils/setup';
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';

Expand All @@ -18,7 +18,7 @@ describe('collect config', () => {
]);

expect(stdout).toContain('LH Configuration is used from a user flow file');
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);
});

Expand Down Expand Up @@ -69,7 +69,7 @@ describe('collect config', () => {
expect(stdout).toContain(
'LH Configuration ./lh-config.json is used from CLI param or .user-flowrc.json',
);
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);
});
});
6 changes: 3 additions & 3 deletions e2e/cli-e2e/tests/collect/dry-run.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';

import { CliTest, DEFAULT_RC, USER_FLOW_MOCKS } from '../../utils/setup';
import { CliTest, DEFAULT_RC, stripNodeWarnings, USER_FLOW_MOCKS } from '../../utils/setup';

describe('collect --dry-run', () => {

Expand All @@ -10,7 +10,7 @@ describe('collect --dry-run', () => {

const { code, stdout, stderr } = await cli.run('user-flow', ['collect', '--dry-run']);

expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(stdout).toBe('');
expect(code).toBe(0);
});
Expand All @@ -24,7 +24,7 @@ describe('collect --dry-run --verbose', () => {

const { code, stdout, stderr } = await cli.run('user-flow', ['collect', '--dry-run', '--verbose']);

expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(stdout).not.toBe('');
expect(code).toBe(0);
});
Expand Down
8 changes: 4 additions & 4 deletions e2e/cli-e2e/tests/collect/format.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
import { readdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';

import { CliTest, DEFAULT_RC, USER_FLOW_MOCKS } from '../../utils/setup';
import { CliTest, DEFAULT_RC, stripNodeWarnings, USER_FLOW_MOCKS } from '../../utils/setup';

const DUMMY_USER_FLOW_NAME = 'Basic Navigation Example';
const MOCK_MD_REPORT_HEADER = '| Gather Mode | Performance | Accessibility | Best Practices | Seo |';
Expand All @@ -16,7 +16,7 @@ describe('collect format', () => {

const { code, stderr } = await cli.run('user-flow', ['collect']);

expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);

const resultFileNames = getResultFile(root);
Expand All @@ -36,7 +36,7 @@ describe('collect format', () => {

expect(stdout).toContain(MOCK_MD_REPORT_HEADER)
expect(stdout).toContain(DUMMY_USER_FLOW_NAME);
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);
});

Expand All @@ -57,7 +57,7 @@ describe('collect format', () => {

expect(stdout).toContain(MOCK_MD_REPORT_HEADER)
expect(stdout).toContain(DUMMY_USER_FLOW_NAME);
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);
})
});
Expand Down
8 changes: 4 additions & 4 deletions e2e/cli-e2e/tests/init/init.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect } from 'vitest';
import { CliTest, DEFAULT_RC, KEYBOARD, USER_FLOW_MOCKS } from '../../utils/setup';
import { CliTest, DEFAULT_RC, KEYBOARD, stripNodeWarnings, USER_FLOW_MOCKS } from '../../utils/setup';
import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';

Expand All @@ -26,7 +26,7 @@ describe('init command', () => {
const { code, stdout, stderr} = await cli.waitForClose();

expect(stdout).toContain('user-flow CLI is set up now! 🎉');
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);
});

Expand All @@ -37,7 +37,7 @@ describe('init command', () => {
const { code, stdout, stderr} = await cli.run('user-flow', ['init']);

expect(stdout).toContain('user-flow CLI is set up now! 🎉');
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);
});

Expand All @@ -48,7 +48,7 @@ describe('init command', () => {
const { code, stdout, stderr} = await cli.run('user-flow', ['init', '--generateGhWorkflow']);

expect(stdout).toContain('user-flow CLI is set up now! 🎉');
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);
expect(existsSync(join(root, '.github', 'workflows', 'user-flow-ci.yml'))).toBeTruthy();
});
Expand Down
10 changes: 5 additions & 5 deletions e2e/cli-e2e/tests/init/rc-config.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { CliTest, DEFAULT_RC, KEYBOARD } from '../../utils/setup';
import { CliTest, DEFAULT_RC, KEYBOARD, stripNodeWarnings } from '../../utils/setup';
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';

Expand All @@ -18,7 +18,7 @@ describe('.rc.json in empty sandbox', () => {
]);

const { code, stderr } = await cli.waitForClose();
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);

const rc = JSON.parse(
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('.rc.json in empty sandbox', () => {
]);

const { code, stderr } = await cli.waitForClose();
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);

const rc = JSON.parse(
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('.rc.json in empty sandbox', () => {
]);

const { code, stderr } = await cli.waitForClose();
expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);

const rc = JSON.parse(
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('.rc.json in remote sandbox', () => {
expect(stdout).toContain(`outPath: '${DEFAULT_RC.persist.outPath}'`);
expect(stdout).toContain(`format: [ '${DEFAULT_RC.persist.format}' ]`);

expect(stderr).toBe('');
expect(stripNodeWarnings(stderr)).toBe('');
expect(code).toBe(0);
});
});
Expand Down
20 changes: 20 additions & 0 deletions e2e/cli-e2e/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,23 @@ export type CliTest = {
code: number | null;
}
};

/**
* Node writes its own diagnostics to the CLI's stderr - deprecation and
* experimental warnings that come from the runtime, not from user-flow. They
* vary by Node version, so asserting on raw stderr makes the suite pass or fail
* on which Node happens to be installed rather than on the CLI's behaviour.
*
* Strips those lines so a test can still assert the CLI itself stayed quiet.
*/
export function stripNodeWarnings(stderr: string): string {
return stderr
// `(node:123) [DEP0205] DeprecationWarning: ...`
.replace(/^\(node:\d+\) .*(?:\r?\n|$)/gm, '')
// the follow-up hint Node prints under a warning
.replace(
/^\(Use `node --trace-\S+ \.\.\.` to show where the warning was created\)(?:\r?\n|$)/gm,
''
)
.trim();
}
3 changes: 3 additions & 0 deletions e2e/nx-plugin-e2e/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import baseConfig from '../../eslint.config.mjs';

export default [...baseConfig];
25 changes: 25 additions & 0 deletions e2e/nx-plugin-e2e/fixtures/workspace/nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": ["default"],
"sharedGlobals": []
},
"plugins": [
{
"plugin": "@nx/js/typescript",
"options": {
"typecheck": {
"targetName": "typecheck"
},
"build": {
"targetName": "build",
"configName": "tsconfig.lib.json",
"buildDepsName": "build-deps",
"watchDepsName": "watch-deps"
}
}
}
],
"analytics": false
}
Loading
Loading