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

Unit test fails when a library is imported locally #951

Closed
Overdrivr opened this issue Mar 7, 2018 · 3 comments
Closed

Unit test fails when a library is imported locally #951

Overdrivr opened this issue Mar 7, 2018 · 3 comments

Comments

@Overdrivr
Copy link

Version

2.9.3

Reproduction link

https://gitlab.com/cronobo/vue-e2e-test

Steps to reproduce

  1. Scaffold app
  2. Install a library (I tried with vue-octicon and vue-ionicons)
  3. Import locally this lib into HelloWorld component
  4. npm run dev works fine, icon is rendered
  5. Yet, npm run unit crashes with a weird SyntaxError

What is expected?

No SyntaxError, since html was not even modified

What is actually happening?

> jest --config test/unit/jest.conf.js --coverage

● Deprecation Warning:

  Option "mapCoverage" has been removed, as it's no longer necessary.

  Please update your configuration.

  Configuration Documentation:
  https://facebook.github.io/jest/docs/configuration.html

 FAIL  test\unit\specs\HelloWorld.spec.js
  ● Test suite failed to run

    C:\Users\remib\Gitlab\vue-e2e-test\node_modules\vue-ionicons\dist\md-alert.vue:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){<template>
                                                                                             ^

    SyntaxError: Unexpected token <

       6 |       <li>
       7 |         <a
    >  8 |           href="https://vuejs.org"
       9 |           target="_blank"
      10 |         >
      11 |           Core Docs

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
      at src/components/HelloWorld.vue:8:68
      at Object.<anonymous> (src/components/HelloWorld.vue:106:3)

Running coverage on untested files...Failed to collect coverage from C:\Users\remib\Gitlab\vue-e2e-test\src\components\HelloWorld.vue
ERROR: Cannot read property 'fileCoverage' of undefined
STACK: TypeError: Cannot read property 'fileCoverage' of undefined
    at Instrumenter.instrumentSync (C:\Users\remib\Gitlab\vue-e2e-test\node_modules\istanbul-lib-instrument\dist\instrumenter.js:148:40)
    at exports.default (C:\Users\remib\Gitlab\vue-e2e-test\node_modules\jest\node_modules\jest-cli\build\generate_empty_coverage.js:18:18)
    at Object.worker (C:\Users\remib\Gitlab\vue-e2e-test\node_modules\jest\node_modules\jest-cli\build\reporters\coverage_worker.js:48:84)
    at execMethod (C:\Users\remib\Gitlab\vue-e2e-test\node_modules\jest-worker\build\child.js:92:29)
    at process.on (C:\Users\remib\Gitlab\vue-e2e-test\node_modules\jest-worker\build\child.js:42:7)
    at emitTwo (events.js:126:13)
    at process.emit (events.js:214:7)
    at emit (internal/child_process.js:772:12)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |  Unknown |  Unknown |  Unknown |  Unknown |                   |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.719s
Ran all test suites.
@UrsMetz
Copy link

UrsMetz commented Mar 13, 2018

Maybe this is caused by vuejs/vue-jest#45?

@Overdrivr
Copy link
Author

Overdrivr commented Mar 15, 2018

I will try with mocha to check if this comes from jest or not. Keep you posted

@LinusBorg
Copy link
Member

This is an issue with the webpack template, not vue-cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants