browser-commander 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import assert from 'node:assert/strict';
5
+ import { describe, it } from 'node:test';
6
+
7
+ import { checkWorkflow } from '../../../../scripts/check-ci-workflows.mjs';
8
+
9
+ function withWorkflow(content, callback) {
10
+ const directory = mkdtempSync(join(tmpdir(), 'browser-commander-ci-'));
11
+ const filePath = join(directory, 'workflow.yml');
12
+ writeFileSync(filePath, content);
13
+
14
+ try {
15
+ return callback(filePath);
16
+ } finally {
17
+ rmSync(directory, { force: true, recursive: true });
18
+ }
19
+ }
20
+
21
+ describe('CI workflow policy', () => {
22
+ it('accepts bounded job-scoped checks', () => {
23
+ const workflow = `name: Test
24
+ on: push
25
+ permissions:
26
+ contents: read
27
+ env:
28
+ GIT_CONFIG_KEY_0: init.defaultBranch
29
+ jobs:
30
+ test:
31
+ runs-on: ubuntu-latest
32
+ timeout-minutes: 5
33
+ concurrency:
34
+ group: \${{ github.workflow }}-\${{ github.ref }}-test
35
+ cancel-in-progress: true
36
+ steps:
37
+ - uses: actions/checkout@v6
38
+ `;
39
+
40
+ withWorkflow(workflow, (filePath) => {
41
+ assert.equal(checkWorkflow(filePath), 0);
42
+ });
43
+ });
44
+
45
+ it('rejects workflow-wide cancellation and unbounded jobs', () => {
46
+ const workflow = `name: Test
47
+ on: push
48
+ concurrency:
49
+ group: test
50
+ cancel-in-progress: true
51
+ jobs:
52
+ test:
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - uses: actions/checkout@v6
56
+ - run: npm install
57
+ - run: echo "\${{ github.head_ref }}"
58
+ - uses: codecov/codecov-action@v6
59
+ with:
60
+ file: coverage.xml
61
+ `;
62
+ const originalError = console.error;
63
+ console.error = () => {};
64
+
65
+ try {
66
+ withWorkflow(workflow, (filePath) => {
67
+ assert.equal(checkWorkflow(filePath), 7);
68
+ });
69
+ } finally {
70
+ console.error = originalError;
71
+ }
72
+ });
73
+ });
@@ -127,12 +127,25 @@ describe('test runner helper', () => {
127
127
  reporter: 'spec',
128
128
  targets: ['tests/unit'],
129
129
  });
130
- assert.deepEqual(buildNodeTestArgs(options, ['tests/unit/a.test.js']), [
131
- '--test',
132
- '--experimental-test-coverage',
133
- '--test-reporter',
134
- 'spec',
135
- 'tests/unit/a.test.js',
136
- ]);
130
+ assert.deepEqual(
131
+ buildNodeTestArgs(options, ['tests/unit/a.test.js'], '24.18.0'),
132
+ [
133
+ '--test',
134
+ '--test-isolation=none',
135
+ '--experimental-test-coverage',
136
+ '--test-reporter',
137
+ 'spec',
138
+ 'tests/unit/a.test.js',
139
+ ]
140
+ );
141
+ });
142
+
143
+ it('keeps process isolation on Node versions without isolation controls', () => {
144
+ const options = parseTestRunnerArgs(['tests/unit']);
145
+
146
+ assert.deepEqual(
147
+ buildNodeTestArgs(options, ['tests/unit/a.test.js'], '20.20.2'),
148
+ ['--test', 'tests/unit/a.test.js']
149
+ );
137
150
  });
138
151
  });