From 662b1d38b98b1ed7c1f2066846e6589d9832b006 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Tue, 6 Nov 2018 19:49:52 +0800 Subject: [PATCH] test: fix eslint test in CI environment --- .../cli-plugin-eslint/__tests__/eslintPlugin.spec.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/@vue/cli-plugin-eslint/__tests__/eslintPlugin.spec.js b/packages/@vue/cli-plugin-eslint/__tests__/eslintPlugin.spec.js index 9291c026c3..ace70cf408 100644 --- a/packages/@vue/cli-plugin-eslint/__tests__/eslintPlugin.spec.js +++ b/packages/@vue/cli-plugin-eslint/__tests__/eslintPlugin.spec.js @@ -72,15 +72,17 @@ test('should work', async () => { let isFirstMsg = true server.stdout.on('data', data => { data = data.toString() - if (data.match(/Compiled with \d warning/)) { + if (isFirstMsg) { // should fail on start - expect(isFirstMsg).toBe(true) + expect(data).toMatch(/Compiled with \d warning/) isFirstMsg = false + // fix it write('src/App.vue', app) } else if (data.match(/Compiled successfully/)) { - // should compile on 2nd update - expect(isFirstMsg).toBe(false) + // should compile on the subsequent update + // (note: in CI environment this may not be the exact 2nd update, + // so we use data.match as a termination condition rather than a test case) server.stdin.write('close') done() }