Skip to content

Commit b98f931

Browse files
setup(tests): add spawnPromisified & snapshot name utils to project (#71)
1 parent 9b72122 commit b98f931

File tree

7 files changed

+14
-10
lines changed

7 files changed

+14
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"lint:fix": "biome lint --fix ./",
77
"lint": "biome lint ./",
88
"pre-commit": "node --run lint:fix; node --run type-check; node --run test",
9-
"test": "npm run test --workspaces -- --no-warnings --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout",
9+
"test": "npm run test --workspaces -- --no-warnings --import='./test/snapshots.ts' --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout",
1010
"type-check": "tsc"
1111
},
1212
"repository": {

recipes/correct-ts-specifiers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"scripts": {
1111
"start": "node --no-warnings --experimental-import-meta-resolve --experimental-strip-types ./src/workflow.ts",
12-
"test": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --experimental-strip-types --import='../../build/snapshots.mts' --test --experimental-test-coverage --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' './**/*.test.ts'"
12+
"test": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --experimental-strip-types --import='../../test/snapshots.ts' --test --experimental-test-coverage --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' './**/*.test.ts'"
1313
},
1414
"repository": {
1515
"type": "git",

recipes/correct-ts-specifiers/src/logger.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
22
import { execPath } from 'node:process';
33
import { describe, it } from 'node:test';
44

5-
import { spawnPromisified } from '../test/spawn-promisified.ts';
5+
import { spawnPromisified } from '../../../test/spawn-promisified.ts';
66

77
describe('logger', { concurrency: true }, () => {
88
it('should emit non-error entries to standard out, collated by source module', async (t) => {

recipes/correct-ts-specifiers/src/workflow.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { readFile } from 'node:fs/promises';
44
import { describe, it } from 'node:test';
55
import { fileURLToPath } from 'node:url';
66

7-
import { spawnPromisified } from '../test/spawn-promisified.ts';
7+
import { spawnPromisified } from '../../../test/spawn-promisified.ts';
88

99
describe('workflow', () => {
1010
it('should update bad specifiers and ignore good ones', async (t) => {

build/snapshots.mts renamed to test/snapshots.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { snapshot } from 'node:test';
33

44
snapshot.setResolveSnapshotPath(generateSnapshotPath);
55
/**
6-
* @param testFilePath '/tmp/foo.test.js'
7-
* @returns '/tmp/foo.test.snap.cjs'
6+
* @param {string} testFilePath `'/tmp/foo.test.js'`
7+
* @returns `'/tmp/foo.test.snap.cjs'`
8+
* @type {Parameters<snapshot.setResolveSnapshotPath>[0]}
89
*/
9-
function generateSnapshotPath(testFilePath?: string) {
10+
function generateSnapshotPath(testFilePath) {
1011
if (!testFilePath) return '';
1112

1213
const ext = extname(testFilePath);
File renamed without changes.

tsconfig.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"rootDir": "./",
55

66
"target": "ESNext",
7-
"lib": ["ESNext"],
8-
7+
"lib": [
8+
"ESNext"
9+
],
910
/* Modules */
1011
"module": "NodeNext",
1112
"moduleResolution": "nodenext",
@@ -25,6 +26,7 @@
2526
/* Interop Constraints */
2627
"verbatimModuleSyntax": true,
2728
"allowSyntheticDefaultImports": true,
29+
"erasableSyntaxOnly": true,
2830
"esModuleInterop": true,
2931
"forceConsistentCasingInFileNames": true,
3032

@@ -39,7 +41,8 @@
3941
},
4042
"include": [
4143
"./build/",
42-
"./recipes/"
44+
"./recipes/",
45+
"./test",
4346
],
4447
"exclude": [
4548
"node_modules",

0 commit comments

Comments
 (0)