Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vue related tests #122

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions test/integration/vue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'),
Expand All @@ -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$/,
Expand Down Expand Up @@ -82,22 +91,22 @@ 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;
});

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;
});
Expand All @@ -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();
Expand All @@ -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();
Expand Down