Skip to content

Commit 4e93bb8

Browse files
🚧 progress: Add scripts to test build artifacts.
Missing a GitHub workflow: how do we cache builds across workflows? Probably needs `@node-loader/babel` with `{"node": "current"}` to be generic. Would be nice to avoid loading `regenerator-runtime` when not necessary.
1 parent cf7eff2 commit 4e93bb8

17 files changed

+1124
-2227
lines changed

package.json

+14-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"ci:test": "npm run lint-config && npm run lint && npm run cover",
4747
"commit-msg": "commitlint --edit",
4848
"cover": "NODE_ENV=cover c8 --all --src src --reporter lcov --reporter text-summary --reporter text npm test",
49-
"debug": "NODE_ENV=debug npm run test -- -st --fail-fast",
49+
"debug": "NODE_ENV=debug npm test -- -- -- -st --fail-fast",
5050
"dev": "npm run lint-config-and-fix && npm run lint-and-fix && npm run cover -- -- -st --fail-fast",
5151
"install-hooks": "husky install",
5252
"lint": "xo",
@@ -59,7 +59,13 @@
5959
"prepare": "npm run build",
6060
"prepublishOnly": "pinst --disable",
6161
"release": "np --message ':hatching_chick: release: Bumping to v%s.'",
62-
"test": "ava"
62+
"test": "npm run test:src",
63+
"test-cmd": "ava",
64+
"test:cjs": "IMPORT_MAP_PATH=test/import-maps/dist/index.json npm run test-cmd",
65+
"test:dist": "npm run test:modern && npm run test:module && npm run test:cjs",
66+
"test:modern": "IMPORT_MAP_PATH=test/import-maps/dist/index.modern.json npm run test-cmd",
67+
"test:module": "IMPORT_MAP_PATH=test/import-maps/dist/index.module.json npm run test-cmd",
68+
"test:src": "IMPORT_MAP_PATH=test/import-maps/src/index.json npm run test-cmd"
6369
},
6470
"dependencies": {},
6571
"devDependencies": {
@@ -68,7 +74,8 @@
6874
"@babel/register": "7.16.0",
6975
"@commitlint/cli": "15.0.0",
7076
"@js-library/commitlint-config": "0.0.4",
71-
"ava": "3.15.0",
77+
"@node-loader/import-maps": "^1.0.3",
78+
"ava": "^4.0.0-rc.1",
7279
"babel-plugin-transform-remove-console": "6.9.4",
7380
"babel-plugin-unassert": "3.2.0",
7481
"babel-preset-power-assert": "3.0.0",
@@ -93,8 +100,10 @@
93100
"test/src/**/*"
94101
],
95102
"require": [
96-
"regenerator-runtime/runtime",
97-
"@babel/register"
103+
"regenerator-runtime/runtime"
104+
],
105+
"nodeArguments": [
106+
"--experimental-loader=@node-loader/import-maps"
98107
],
99108
"timeout": "1m"
100109
},

test/import-maps/dist/index.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"#module": "./dist/index.cjs"
4+
}
5+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"#module": "./dist/index.modern.js"
4+
}
5+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"#module": "./dist/index.module.js"
4+
}
5+
}

test/import-maps/src/index.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"#module": "./src/index.js"
4+
}
5+
}

test/src/asyncIterator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {fromString} from '../../src/index.js';
3+
import {fromString} from '#module';
44

55
/**
66
* @test {Tape#[Symbol.asyncIterator]}

test/src/fromReadStream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs';
22
import test from 'ava';
33

4-
import {fromReadStream, toString} from '../../src/index.js';
4+
import {fromReadStream, toString} from '#module';
55

66
test('unread token', async (t) => {
77
const filepath = 'test/data/hello-world.txt';

test/src/ignore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {fromString, ignore, toString} from '../../src/index.js';
3+
import {fromString, ignore, toString} from '#module';
44

55
/**
66
* @test {ignore}

test/src/iterator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {fromString} from '../../src/index.js';
3+
import {fromString} from '#module';
44

55
/**
66
* Checks that trying to access the synchronous iterator of a tape throws.

test/src/map.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {fromString, toString, map} from '../../src/index.js';
3+
import {fromString, toString, map} from '#module';
44

55
/**
66
* @test {map}

test/src/promise.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {fromString} from '../../src/index.js';
3+
import {fromString} from '#module';
44

55
/**
66
* @test {fromString}

test/src/skip.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {fromString, skip} from '../../src/index.js';
3+
import {fromString, skip} from '#module';
44

55
/**
66
* @test {fromString}

test/src/split.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {fromString, split, toString} from '../../src/index.js';
3+
import {fromString, split, toString} from '#module';
44

55
/**
66
* @test {split}

test/src/string.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {fromString, toString} from '../../src/index.js';
3+
import {fromString, toString} from '#module';
44

55
/**
66
* @test {fromString}

test/src/toAsyncCallable.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import test from 'ava';
22

3-
import {
4-
fromString,
5-
toAsyncCallable,
6-
fromCallable,
7-
toString,
8-
} from '../../src/index.js';
3+
import {fromString, toAsyncCallable, fromCallable, toString} from '#module';
94

105
/**
116
* @test {toAsyncCallable}

test/src/unread.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import test from 'ava';
22

3-
import {
4-
fromString,
5-
toAsyncCallable,
6-
fromCallable,
7-
toString,
8-
} from '../../src/index.js';
3+
import {fromString, toAsyncCallable, fromCallable, toString} from '#module';
94

105
/**
116
* @test {Tape#unread}

0 commit comments

Comments
 (0)