Skip to content

Commit 17b0e99

Browse files
committed
Include test files in 'tsconfig.json' (but exclude from distribution)
1 parent 3704015 commit 17b0e99

7 files changed

+22
-12
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"scripts": {
3333
"lint": "eslint -c .eslintrc.json --ext .ts src test",
3434
"prebuild": "rimraf dist",
35-
"build:cjs": "tsc --module commonjs --moduleResolution node --outDir dist/commonjs",
36-
"build:esm": "tsc --outDir dist/module",
35+
"build:cjs": "tsc -p tsconfig.dist.json --module commonjs --moduleResolution node --outDir dist/commonjs",
36+
"build:esm": "tsc -p tsconfig.dist.json --outDir dist/module",
3737
"test": "node --experimental-default-type module --loader ts-node/esm --enable-source-maps --test test/*.test.ts",
3838
"test:prod": "npm run lint && npm run test"
3939
},

test/client.test.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { env, hrtime } from 'node:process';
44
import { describe } from 'node:test';
55
import { equal, deepEqual, rejects, strictEqual } from 'node:assert';
66

7-
import { test } from './helper';
7+
import { test } from './helper.js';
88
import {
99
Client,
1010
DataFormat,
@@ -13,9 +13,10 @@ import {
1313
PreparedStatement,
1414
Result,
1515
ResultIterator,
16+
ResultRecord,
1617
SSLMode,
17-
} from '../src/index';
18-
import { postgresqlErrorCodes } from '../src/errors';
18+
} from '../src/index.js';
19+
import { postgresqlErrorCodes } from '../src/errors.js';
1920

2021
// Adjust for benchmarking mode.
2122
const benchmarkEnabled = env.NODE_ENV === 'benchmark';
@@ -351,7 +352,7 @@ describe('Query', () => {
351352
});
352353

353354
interface QueryTest {
354-
query: ResultIterator;
355+
query: ResultIterator<ResultRecord>;
355356
expectation:
356357
| {
357358
names: string[];

test/helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, test } from 'node:test';
2-
import { Client, Configuration, connect } from '../src/index';
2+
import { Client, Configuration, connect } from '../src/index.js';
33

44
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
55
type Test = (context: {

test/result.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { equal, deepEqual, rejects, strictEqual } from 'node:assert';
22
import { describe } from 'node:test';
3-
import { test } from './helper';
4-
import { Client, ResultIterator, ResultRow } from '../src/index';
3+
import { test } from './helper.js';
4+
import { Client, ResultIterator, ResultRow } from '../src/index.js';
55

66
type ResultFunction<T> = (result: ResultIterator<T>) => Promise<T[]>;
77

test/types.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Buffer } from 'node:buffer';
22
import { strict as assert } from 'node:assert';
33
import { describe } from 'node:test';
4-
import { test } from './helper';
4+
import { test } from './helper.js';
55

6-
import { DataType, Point, DataFormat } from '../src/index';
6+
import { DataType, Point, DataFormat } from '../src/index.js';
77

88
const infinity = Number('Infinity');
99

tsconfig.dist.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": [
4+
"test/*.ts"
5+
]
6+
}

tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@
2121
"transpileOnly": true,
2222
"esm": true,
2323
},
24-
"include": ["src/*.ts"],
24+
"include": [
25+
"src/*.ts",
26+
"test/*.ts"
27+
],
2528
}

0 commit comments

Comments
 (0)