Skip to content

Commit 750ee7f

Browse files
committed
test(typescript): fix tests related to rollup's new logging
See rollup/rollup#5424
1 parent 1557462 commit 750ee7f

File tree

7 files changed

+48
-21
lines changed

7 files changed

+48
-21
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Snapshot report for `test/test.js`
2+
3+
The actual snapshot is saved in `test.js.snap`.
4+
5+
Generated by [AVA](https://avajs.dev).
6+
7+
## warns for invalid module types
8+
9+
> Snapshot 1
10+
11+
[
12+
{
13+
code: 'PLUGIN_WARNING',
14+
message: '[plugin typescript] @rollup/plugin-typescript TS6046: Argument for \'--module\' option must be: \'none\', \'commonjs\', \'amd\', \'system\', \'umd\', \'es6\', \'es2015\', \'es2020\', \'es2022\', \'esnext\', \'node16\', \'node18\', \'node20\', \'nodenext\', \'preserve\'.',
15+
plugin: 'typescript',
16+
pluginCode: 'TS6046',
17+
[Symbol(augmented)]: true,
18+
},
19+
]
20+
21+
## should throw on bad options
22+
23+
> Snapshot 1
24+
25+
[
26+
{
27+
code: 'PLUGIN_WARNING',
28+
message: '[plugin typescript] @rollup/plugin-typescript TS5023: Unknown compiler option \'foo\'.',
29+
plugin: 'typescript',
30+
pluginCode: 'TS5023',
31+
[Symbol(augmented)]: true,
32+
},
33+
]
534 Bytes
Binary file not shown.

packages/typescript/test/snapshots/tslib.ts.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ Generated by [AVA](https://avajs.dev).
2828
code: 'PLUGIN_ERROR',
2929
hook: 'buildStart',
3030
plugin: 'typescript',
31-
message: '@rollup/plugin-typescript: Could not find module \'tslib\', which is required by this plugin. Is it installed?',
31+
[Symbol(augmented)]: true,
32+
message: '[plugin typescript] @rollup/plugin-typescript: Could not find module \'tslib\', which is required by this plugin. Is it installed?',
3233
}
40 Bytes
Binary file not shown.

packages/typescript/test/snapshots/warnings.ts.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Generated by [AVA](https://avajs.dev).
1111
[
1212
{
1313
code: 'PLUGIN_WARNING',
14-
message: '@rollup/plugin-typescript: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a "module" other than "esnext". Unless you know what you\'re doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.',
14+
message: '[plugin typescript] @rollup/plugin-typescript: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a "module" other than "esnext". Unless you know what you\'re doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.',
1515
plugin: 'typescript',
16+
[Symbol(augmented)]: true,
1617
},
1718
]
41 Bytes
Binary file not shown.

packages/typescript/test/test.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,7 @@ test.serial('warns for invalid module types', async (t) => {
311311
})
312312
);
313313

314-
t.deepEqual(warnings, [
315-
{
316-
code: 'PLUGIN_WARNING',
317-
plugin: 'typescript',
318-
pluginCode: 'TS6046',
319-
message: `@rollup/plugin-typescript TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'node18', 'node20', 'nodenext', 'preserve'.`
320-
}
321-
]);
314+
t.snapshot(warnings);
322315
});
323316

324317
test.serial('ignores case of module types', async (t) => {
@@ -398,7 +391,10 @@ test.serial('reports diagnostics and throws if errors occur during transpilation
398391
})
399392
);
400393

401-
t.is(caughtError.message, '@rollup/plugin-typescript TS1110: Type expected.');
394+
t.is(
395+
caughtError.message,
396+
'[plugin typescript] fixtures/syntax-error/missing-type.ts (1:8): @rollup/plugin-typescript TS1110: Type expected.'
397+
);
402398
t.is(caughtError.pluginCode, 'TS1110');
403399
});
404400

@@ -420,7 +416,10 @@ test.serial('ignore type errors if noEmitOnError is false', async (t) => {
420416
t.is(warnings[0].code, 'PLUGIN_WARNING');
421417
t.is(warnings[0].plugin, 'typescript');
422418
t.is(warnings[0].pluginCode, 'TS1110');
423-
t.is(warnings[0].message, '@rollup/plugin-typescript TS1110: Type expected.');
419+
t.is(
420+
warnings[0].message,
421+
'[plugin typescript] fixtures/syntax-error/missing-type.ts (1:8): @rollup/plugin-typescript TS1110: Type expected.'
422+
);
424423

425424
t.is(warnings[0].loc.line, 1);
426425
t.is(warnings[0].loc.column, 8);
@@ -640,18 +639,11 @@ test.serial('should throw on bad options', async (t) => {
640639
}
641640
}),
642641
{
643-
message: "@rollup/plugin-typescript: Couldn't process compiler options"
642+
message: "[plugin typescript] @rollup/plugin-typescript: Couldn't process compiler options"
644643
}
645644
);
646645

647-
t.deepEqual(warnings, [
648-
{
649-
code: 'PLUGIN_WARNING',
650-
plugin: 'typescript',
651-
pluginCode: 'TS5023',
652-
message: `@rollup/plugin-typescript TS5023: Unknown compiler option 'foo'.`
653-
}
654-
]);
646+
t.snapshot(warnings);
655647
});
656648

657649
test.serial('should handle re-exporting types', async (t) => {

0 commit comments

Comments
 (0)