|
1 |
| -jest.setTimeout(35000) |
| 1 | +jest.setTimeout(300000) |
2 | 2 |
|
3 | 3 | const path = require('path')
|
4 | 4 | const { linkBin } = require('@vue/cli/lib/util/linkBin')
|
@@ -225,3 +225,46 @@ test('should persist cache', async () => {
|
225 | 225 |
|
226 | 226 | expect(has('node_modules/.cache/eslint/cache.json')).toBe(true)
|
227 | 227 | })
|
| 228 | + |
| 229 | +test(`should use formatter 'codeframe'`, async () => { |
| 230 | + const project = await create('eslint-formatter-codeframe', { |
| 231 | + plugins: { |
| 232 | + '@vue/cli-plugin-babel': {}, |
| 233 | + '@vue/cli-plugin-eslint': { |
| 234 | + config: 'airbnb', |
| 235 | + lintOn: 'save' |
| 236 | + } |
| 237 | + } |
| 238 | + }) |
| 239 | + const { read, write, run } = project |
| 240 | + const main = await read('src/main.js') |
| 241 | + expect(main).toMatch(';') |
| 242 | + |
| 243 | + let done |
| 244 | + const donePromise = new Promise(resolve => { |
| 245 | + done = resolve |
| 246 | + }) |
| 247 | + // remove semicolons |
| 248 | + const updatedMain = main.replace(/;/g, '') |
| 249 | + await write('src/main.js', updatedMain) |
| 250 | + |
| 251 | + const server = run('vue-cli-service serve') |
| 252 | + |
| 253 | + let isFirstMsg = true |
| 254 | + server.stdout.on('data', data => { |
| 255 | + data = data.toString() |
| 256 | + if (isFirstMsg) { |
| 257 | + expect(data).toMatch(/Failed to compile with \d error/) |
| 258 | + isFirstMsg = false |
| 259 | + } else if (data.match(/semi/)) { |
| 260 | + // check the format of output |
| 261 | + // https://eslint.org/docs/user-guide/formatters/#codeframe |
| 262 | + expect(data).toMatch(`error: Missing semicolon (semi) at src${path.sep}main.js`) |
| 263 | + |
| 264 | + server.stdin.write('close') |
| 265 | + done() |
| 266 | + } |
| 267 | + }) |
| 268 | + |
| 269 | + await donePromise |
| 270 | +}) |
0 commit comments