From d6e0b39c3ad82aef75297a5635e5229bd8b081c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Gr=C3=B6hbiel?= Date: Sun, 8 May 2016 23:34:53 +0100 Subject: [PATCH] [#190] Scenario: typescript compilation errors prevent test run --- .gitignore | 3 ++- test/integration/karma.conf.js | 14 ++++++++++---- test/integration/ts/A.spec.ts | 21 +++++++++++++++++++++ test/integration/ts/A.ts | 7 +++++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 test/integration/ts/A.spec.ts create mode 100644 test/integration/ts/A.ts diff --git a/.gitignore b/.gitignore index 104d999..02a6999 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -tmp/ \ No newline at end of file +tmp/ +.idea/ \ No newline at end of file diff --git a/test/integration/karma.conf.js b/test/integration/karma.conf.js index c17039e..388924a 100644 --- a/test/integration/karma.conf.js +++ b/test/integration/karma.conf.js @@ -25,7 +25,10 @@ module.exports = function(karma) { 'test/*Spec.js', // a helper, accidently included with the tests - 'test/helper.js' + 'test/helper.js', + + // tests written in typescript + 'ts/*.spec.ts' ], reporters: [ 'dots' ], @@ -33,7 +36,8 @@ module.exports = function(karma) { preprocessors: { 'lib/a.js': [ 'browserify' ], 'test/*Spec.js': [ 'browserify' ], - 'test/helper.js': [ 'browserify' ] + 'test/helper.js': [ 'browserify' ], + 'ts/*.ts': [ 'browserify' ] }, browsers: [ 'PhantomJS' ], @@ -50,11 +54,13 @@ module.exports = function(karma) { // configure browserify configure: function(b) { - b.on('prebundle', function() { b.external('lib/common.js'); }); - } + }, + plugin: [ + ['tsify'] + ] } }); }; diff --git a/test/integration/ts/A.spec.ts b/test/integration/ts/A.spec.ts new file mode 100644 index 0000000..7de8ce2 --- /dev/null +++ b/test/integration/ts/A.spec.ts @@ -0,0 +1,21 @@ +import {A} from "./A"; + +describe('TypeScript Class A', () => { + it('should instantiate a class', () => { + let instance:A = new A(); + console.warn('this test should run despite the compilation errors!') + expect(instance).toBeDefined(); + }) + } +) + +// uncomment following declarations, to make the typescript compile without errors +// and you will see the test is then executed. +/* +declare class assert { + toBeDefined() +} +declare function expect(obj:any):assert +declare function it(descrption:string, cb:Function) +declare function describe(descrption:string, cb:Function) +*/ diff --git a/test/integration/ts/A.ts b/test/integration/ts/A.ts new file mode 100644 index 0000000..750e045 --- /dev/null +++ b/test/integration/ts/A.ts @@ -0,0 +1,7 @@ +export class A { + private time:Date; + + constructor() { + this.time = new Date() + } +} \ No newline at end of file