Vue-jest: got Unexpected token error on loading ts config

Created on 22 Jul 2019  路  3Comments  路  Source: vuejs/vue-jest

tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "noImplicitAny": false,
    "types": [
      "webpack-env",
      "jest"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ],
    },
    "lib": [
      "esnext",
      "dom",
      "es5",
      "es6",
      "es2015.promise",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

jest config

"jest": {
    "globals": {
      "vue-jest": {
        "tsConfig": "./tsconfig.json"
      }
    },
    "moduleFileExtensions": [
      "js",
      "ts",
      "json",
      "vue"
    ],
    "transform": {
      ".*\\.(vue)$": "vue-jest",
      "^.+\\.tsx?$": "ts-jest"
    },
    "testURL": "test.url.com",
    "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$"
  }

run npm run test then got error messsage

SyntaxError: .../.../tsconfig.json: Unexpected token } in JSON at position 468
        at JSON.parse (<anonymous>)

      at loadTypescriptConfig (node_modules/vue-jest/lib/load-typescript-config.js:55:30)
      at compileTypescript (node_modules/vue-jest/lib/compilers/typescript-compiler.js:9:20)
      at processScript (node_modules/vue-jest/lib/process.js:23:12)
      at Object.module.exports [as process] (node_modules/vue-jest/lib/process.js:42:18)

Most helpful comment

Hey @AlllenShen , your tslint.config.json is invalid. There's a trailing comma at the closing bracket of your first path which results in invalid JSON.

To quickly debug this I usually use https://jsonlint.com/

Happy coding!

All 3 comments

Hey @AlllenShen , your tslint.config.json is invalid. There's a trailing comma at the closing bracket of your first path which results in invalid JSON.

To quickly debug this I usually use https://jsonlint.com/

Happy coding!

@vanhoofmaarten Thank you so much馃榿

@AlllenShen My pleasure. Don't forget to close this issue if it solves your problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eddyerburgh picture eddyerburgh  路  7Comments

mazipan picture mazipan  路  10Comments

aantipov picture aantipov  路  8Comments

yohodopo picture yohodopo  路  4Comments

xereda picture xereda  路  4Comments