Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit 15d4961

Browse files
committed
Add test for diagnostics
1 parent 37bfc90 commit 15d4961

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var a: ;

test/test.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,44 @@ describe( 'rollup-plugin-typescript', function () {
88
this.timeout( 5000 );
99

1010
it( 'runs code through typescript', function () {
11-
var start = Date.now();
12-
1311
return rollup.rollup({
1412
entry: 'sample/basic/main.ts',
1513
plugins: [
1614
typescript()
1715
]
1816
}).then( function ( bundle ) {
19-
console.log( 'bundled in %s ms', Date.now() - start );
20-
21-
start = Date.now();
2217
const generated = bundle.generate();
23-
console.log( 'generated in %s ms', Date.now() - start );
24-
2518
const code = generated.code;
2619

2720
assert.ok( code.indexOf( 'number' ) === -1, code );
2821
assert.ok( code.indexOf( 'const' ) === -1, code );
2922
});
3023
});
3124

32-
it( 'transpiles ES6 features to ES5', function () {
33-
var start = Date.now();
34-
25+
it( 'transpiles ES6 features to ES5 with source maps', function () {
3526
return rollup.rollup({
3627
entry: 'sample/import-class/main.ts',
3728
plugins: [
3829
typescript()
3930
]
4031
}).then( function ( bundle ) {
41-
console.log( 'bundled in %s ms', Date.now() - start );
42-
43-
start = Date.now();
4432
const generated = bundle.generate();
45-
console.log( 'generated in %s ms', Date.now() - start );
46-
4733
const code = generated.code;
4834

4935
assert.ok( code.indexOf( 'class' ) === -1, code );
5036
assert.ok( code.indexOf( '...' ) === -1, code );
5137
assert.ok( code.indexOf( '=>' ) === -1, code );
5238
});
5339
});
40+
41+
it( 'reports diagnostics and throws if errors occur during transpilation', function () {
42+
return rollup.rollup({
43+
entry: 'sample/syntax-error/missing-type.ts',
44+
plugins: [
45+
typescript()
46+
]
47+
}).catch( function ( error ) {
48+
assert.ok( error.message.indexOf( 'There were TypeScript errors' ) === 0, 'Should reject erroneous code.' );
49+
});
50+
});
5451
});

0 commit comments

Comments
 (0)