From 1d18b7525553be25314ccb0cd45daa9cd1a21605 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 4 Jun 2018 11:53:04 -0400 Subject: [PATCH] Fix vue related tests --- test/integration/vue.spec.js | 53 +++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/test/integration/vue.spec.js b/test/integration/vue.spec.js index ab98744b..a29b0bb3 100644 --- a/test/integration/vue.spec.js +++ b/test/integration/vue.spec.js @@ -12,7 +12,7 @@ var webpackMajorVersion = require('./webpackVersion')(); describe('[INTEGRATION] vue', function () { this.timeout(60000); - process.setMaxListeners(0); + process.setMaxListeners(0); var plugin; var files; var compiler; @@ -21,6 +21,15 @@ describe('[INTEGRATION] vue', function () { function createCompiler(options) { plugin = new ForkTsCheckerWebpackPlugin(Object.assign({}, options, { silent: true })); + var tsLoader = { + loader: 'ts-loader', + options: { + appendTsSuffixTo: [/\.vue$/], + transpileOnly: true, + silent: true + } + } + compiler = webpack({ ...(webpackMajorVersion >= 4 ? { mode: 'development' } : {}), context: path.resolve(__dirname, './vue'), @@ -38,16 +47,16 @@ describe('[INTEGRATION] vue', function () { rules: [ { test: /\.vue$/, - loader: 'vue-loader' + loader: 'vue-loader', + options: { + loaders: { + ts: tsLoader + } + } }, { test: /\.ts$/, - loader: 'ts-loader', - options: { - appendTsSuffixTo: [/\.vue$/], - transpileOnly: true, - silent: true - } + use: tsLoader }, { test: /\.css$/, @@ -82,10 +91,10 @@ describe('[INTEGRATION] vue', function () { createCompiler({ vue: true }); var fileFound; - + fileFound = checker.programConfig.fileNames.indexOf(files['example.vue']) >= 0; expect(fileFound).to.be.true; - + fileFound = checker.programConfig.fileNames.indexOf(files['syntacticError.ts']) >= 0; expect(fileFound).to.be.true; }); @@ -93,11 +102,11 @@ describe('[INTEGRATION] vue', function () { it('should not create a Vue program config if vue=false', function () { createCompiler(); - var fileFound; - + var fileFound; + fileFound = checker.programConfig.fileNames.indexOf(files['example.vue']) >= 0; expect(fileFound).to.be.false; - + fileFound = checker.programConfig.fileNames.indexOf(files['syntacticError.ts']) >= 0; expect(fileFound).to.be.true; }); @@ -109,33 +118,33 @@ describe('[INTEGRATION] vue', function () { source = checker.program.getSourceFile(files['example.vue']); expect(source).to.not.be.undefined; - + source = checker.program.getSourceFile(files['syntacticError.ts']); - expect(source).to.not.be.undefined; + expect(source).to.not.be.undefined; }); it('should not create a Vue program if vue=false', function () { createCompiler(); - + var source; - + source = checker.program.getSourceFile(files['example.vue']); expect(source).to.be.undefined; - + source = checker.program.getSourceFile(files['syntacticError.ts']); - expect(source).to.not.be.undefined; + expect(source).to.not.be.undefined; }); it('should get syntactic diagnostics from Vue program', function () { createCompiler({ tslint: true, vue: true }); const diagnostics = checker.program.getSyntacticDiagnostics(); - expect(diagnostics.length).to.be.equal(1); + expect(diagnostics.length).to.be.equal(1); }); it('should not find syntactic errors when checkSyntacticErrors is false', function (callback) { createCompiler({ tslint: true, vue: true }); - + compiler.run(function(error, stats) { expect(stats.compilation.errors.length).to.be.equal(1); callback(); @@ -144,7 +153,7 @@ describe('[INTEGRATION] vue', function () { it('should find syntactic errors when checkSyntacticErrors is true', function (callback) { createCompiler({ tslint: true, vue: true, checkSyntacticErrors: true }); - + compiler.run(function(error, stats) { expect(stats.compilation.errors.length).to.be.equal(2); callback();