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
7 changes: 5 additions & 2 deletions lib/content/_step-test-yml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
- name: Test (with coverage on Node >= 24)
if: $\{{ startsWith(matrix.node-version, '24') }}
run: {{ rootNpmPath }} run test:cover --ignore-scripts {{~#if jobRunFlags}} {{ jobRunFlags }}{{/if}}
- name: Test (without coverage on Node < 24)
if: $\{{ !startsWith(matrix.node-version, '24') }}
- name: Test (on Node 20 with globbing workaround)
if: $\{{ startsWith(matrix.node-version, '20') }}
run: {{ rootNpmPath }} run test:node20 --ignore-scripts {{~#if jobRunFlags}} {{ jobRunFlags }}{{/if}}
- name: Test
if: $\{{ !startsWith(matrix.node-version, '24') && !startsWith(matrix.node-version, '20') }}
run: {{ rootNpmPath }} test --ignore-scripts {{~#if jobRunFlags}} {{ jobRunFlags }}{{/if}}
{{else}}
- name: Test
Expand Down
1 change: 1 addition & 0 deletions lib/content/package-json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{{#if isNodeTest}}
"snap": "node --test --test-update-snapshots './test/**/*.js'",
"test": "node --test './test/**/*.js'",
"test:node20": "node --test test",
"test:cover": "node --test --experimental-test-coverage --test-timeout=3000{{#if coverageThreshold}} --test-coverage-lines={{coverageThreshold}} --test-coverage-functions={{coverageThreshold}} --test-coverage-branches={{coverageThreshold}}{{/if}} './test/**/*.js'",
{{else}}
"snap": "{{#if typescript}}{{#if tap16}}c8 {{/if}}{{/if}}tap",
Expand Down
6 changes: 4 additions & 2 deletions test/apply/node-test-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ t.test('CI workflow with node:test does not include tap matcher', async t => {

// Verify conditional test steps for coverage
t.match(ciWorkflow, /Test \(with coverage on Node >= 24\)/, 'should have test with coverage step for Node >= 24')
t.match(ciWorkflow, /Test \(without coverage on Node < 24\)/, 'should have test without coverage step for Node < 24')
t.match(ciWorkflow, /Test \(on Node 20 with globbing workaround\)/, 'should have test:node20 step for Node 20')
t.match(ciWorkflow, /- name: Test\n\s+if:/, 'should have regular test step for other Node versions')
t.match(ciWorkflow, "startsWith(matrix.node-version, '24')", 'should check if Node version starts with 24')
t.match(ciWorkflow, "!startsWith(matrix.node-version, '24')", 'should check if Node version does not start with 24')
t.match(ciWorkflow, "startsWith(matrix.node-version, '20')", 'should check if Node version starts with 20')
t.match(ciWorkflow, /test:cover/, 'should use test:cover script for Node >= 24')
t.match(ciWorkflow, /test:node20/, 'should use test:node20 script for Node 20')
})

t.test('CI workflow with tap includes tap matcher', async t => {
Expand Down
2 changes: 2 additions & 0 deletions test/apply/node-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ t.test('node:test runner', async t => {

// Verify test scripts are for node:test
t.equal(pkg.scripts.test, "node --test './test/**/*.js'")
t.equal(pkg.scripts['test:node20'], 'node --test test')
t.equal(
pkg.scripts['test:cover'],
"node --test --experimental-test-coverage --test-timeout=3000 --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100 './test/**/*.js'",
Expand Down Expand Up @@ -52,6 +53,7 @@ t.test('node:test runner with incomplete coverage', async t => {

// Verify test scripts are for node:test
t.equal(pkg.scripts.test, "node --test './test/**/*.js'")
t.equal(pkg.scripts['test:node20'], 'node --test test')
t.equal(
pkg.scripts['test:cover'],
"node --test --experimental-test-coverage --test-timeout=3000 './test/**/*.js'",
Expand Down