Skip to content

Failed to collect coverage: ERROR: Unexpected token u in JSON at position 0 #60

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

Closed
mariangemarcano opened this issue Feb 20, 2018 · 4 comments
Labels

Comments

@mariangemarcano
Copy link

I'm hitting the following issue when running jest with code coverage:

Running coverage on untested files...Failed to collect coverage from components
/AppFooter.vue
ERROR: Unexpected token u in JSON at position 0
STACK: SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at compileTypescript (src/node_modules/vue-jest/lib/compilers/typescript-compiler.js:67:44)
at processScript (src/node_modules/vue-jest/lib/process.js:22:12)
at Object.module.exports [as process] (src/node_modules/vue-jest/lib/process.js:71:18)
at ScriptTransformer.transformSource (/node_modules/jest-runtime/build/script_transformer.js:229:35)
at exports.default (/node_modules/jest-cli/build/generate_empty_coverage.js:37:5)
at Object.worker (/node_modules/jest-cli/build/reporters/coverage_worker.js:39:291)
at execMethod (/node_modules/jest-worker/build/child.js:92:29)
at process.on (/node_modules/jest-worker/build/child.js:42:7)
at emitTwo (events.js:126:13)

typescript-compiler.js is failing JSON.parse

this is the component

<template>
<footer class="page-footer center-on-small-only">
    <b-container fluid>
    </b-container>
</footer>
</template>

<script lang="ts">
// @ts-ignore
import Component from 'nuxt-class-component'
import Vue from 'vue'

@Component({})
export default class AppFooter extends Vue {
}
@velidan
Copy link

velidan commented Feb 22, 2018

Have the same issue

@eddyerburgh
Copy link
Member

eddyerburgh commented Feb 22, 2018

Is anybody able to post a minimal reproduction repo?

@mariangemarcano
Copy link
Author

@eddyerburgh this is an example repo https://github.com/mariangemarcano/nuxt-typescript-jest-example
running npm install and then npm run test hits the issue
it is based on https://github.com/nuxt-community/typescript-template

@mariangemarcano
Copy link
Author

Just confirmed the issue is fixed in version https://github.com/vuejs/vue-jest/tree/v2.3.0

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

No branches or pull requests

3 participants