Skip to content

Commit 3ad26de

Browse files
STRd6GeoffreyBooth
andauthored
Fix CI for Node 16.14.x (#5404)
Co-authored-by: Geoffrey Booth <[email protected]>
1 parent 3d39d20 commit 3ad26de

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

docs/v2/test.html

+14-5
Original file line numberDiff line numberDiff line change
@@ -25716,22 +25716,31 @@ <h1>CoffeeScript Test Suite</h1>
2571625716
<script type="text/x-coffeescript" class="test" id="import_assertions">
2571725717
# This file is running in CommonJS (in Node) or as a classic Script (in the browser tests) so it can use import() within an async function, but not at the top level; and we can’t use static import.
2571825718
test "dynamic import assertion", ->
25719-
{ default: secret } = await import('data:application/json,{"ofLife":42}', { assert: { type: 'json' } })
25720-
eq secret.ofLife, 42
25719+
try
25720+
{ default: secret } = await import('data:application/json,{"ofLife":42}', { assert: { type: 'json' } })
25721+
eq secret.ofLife, 42
25722+
catch exception
25723+
# This parses on Node 16.14.x but throws an error because JSON modules aren’t unflagged there yet; remove this try/catch once the unflagging of `--experimental-json-modules` is backported (see https://github.com/nodejs/node/pull/41736#issuecomment-1086738670)
25724+
unless exception.message is 'Invalid module "data:application/json,{"ofLife":42}" has an unsupported MIME type "application/json"'
25725+
throw exception
2572125726

2572225727
test "assert keyword", ->
2572325728
assert = 1
2572425729

25725-
{ default: assert } = await import('data:application/json,{"thatIAm":42}', { assert: { type: 'json' } })
25726-
eq assert.thatIAm, 42
25730+
try
25731+
{ default: assert } = await import('data:application/json,{"thatIAm":42}', { assert: { type: 'json' } })
25732+
eq assert.thatIAm, 42
25733+
catch exception
25734+
# This parses on Node 16.14.x but throws an error because JSON modules aren’t unflagged there yet; remove this try/catch once the unflagging of `--experimental-json-modules` is backported (see https://github.com/nodejs/node/pull/41736#issuecomment-1086738670)
25735+
unless exception.message is 'Invalid module "data:application/json,{"thatIAm":42}" has an unsupported MIME type "application/json"'
25736+
throw exception
2572725737

2572825738
eqJS """
2572925739
import assert from 'regression-test'
2573025740
""", """
2573125741
import assert from 'regression-test';
2573225742
"""
2573325743

25734-
2573525744
test "static import assertion", ->
2573625745
eqJS """
2573725746
import 'data:application/json,{"foo":3}' assert { type: 'json' }

package-lock.json

+16-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/import_assertions.coffee

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
# This file is running in CommonJS (in Node) or as a classic Script (in the browser tests) so it can use import() within an async function, but not at the top level; and we can’t use static import.
22
test "dynamic import assertion", ->
3-
{ default: secret } = await import('data:application/json,{"ofLife":42}', { assert: { type: 'json' } })
4-
eq secret.ofLife, 42
3+
try
4+
{ default: secret } = await import('data:application/json,{"ofLife":42}', { assert: { type: 'json' } })
5+
eq secret.ofLife, 42
6+
catch exception
7+
# This parses on Node 16.14.x but throws an error because JSON modules aren’t unflagged there yet; remove this try/catch once the unflagging of `--experimental-json-modules` is backported (see https://github.com/nodejs/node/pull/41736#issuecomment-1086738670)
8+
unless exception.message is 'Invalid module "data:application/json,{"ofLife":42}" has an unsupported MIME type "application/json"'
9+
throw exception
510

611
test "assert keyword", ->
712
assert = 1
813

9-
{ default: assert } = await import('data:application/json,{"thatIAm":42}', { assert: { type: 'json' } })
10-
eq assert.thatIAm, 42
14+
try
15+
{ default: assert } = await import('data:application/json,{"thatIAm":42}', { assert: { type: 'json' } })
16+
eq assert.thatIAm, 42
17+
catch exception
18+
# This parses on Node 16.14.x but throws an error because JSON modules aren’t unflagged there yet; remove this try/catch once the unflagging of `--experimental-json-modules` is backported (see https://github.com/nodejs/node/pull/41736#issuecomment-1086738670)
19+
unless exception.message is 'Invalid module "data:application/json,{"thatIAm":42}" has an unsupported MIME type "application/json"'
20+
throw exception
1121

1222
eqJS """
1323
import assert from 'regression-test'
1424
""", """
1525
import assert from 'regression-test';
1626
"""
1727

18-
1928
test "static import assertion", ->
2029
eqJS """
2130
import 'data:application/json,{"foo":3}' assert { type: 'json' }

0 commit comments

Comments
 (0)