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 failing #1131

Closed
ghost opened this issue Apr 14, 2018 · 24 comments
Closed

unit test failing #1131

ghost opened this issue Apr 14, 2018 · 24 comments
Labels
needs reproduction This issue is missing a minimal runnable reproduction, provided by the author

Comments

@ghost
Copy link

ghost commented Apr 14, 2018

Version

3.0.0-beta.6

Reproduction link

https://codesandbox.io/s/vue

Steps to reproduce

vue create myproject

Vue CLI v3.0.0-beta.6
? Please pick a preset: full (vue-router, vuex, sass, babel, pwa, eslint, unit-j
est, e2e-nightwatch)

select full

🎉 Successfully created project myproject.
cd myproject

What is expected?

vue-cli-service test passing without error

What is actually happening?

FAIL tests/unit/HelloWorld.spec.js
● Test suite failed to run

  Plugin 0 specified in "/Users/yves/Developments/WIP/VUE.JS-vcli-3-beta/myproject/node_modules/@vue/babel-preset-app/index.js" provided an invalid property of "default" (While processing preset: "..../myproject/node_modules/@vue/babel-preset-app/index.js")
  
    at Plugin.init (node_modules/babel-jest/node_modules/babel-core/lib/transformation/plugin.js:131:13)
        at Array.map (<anonymous>)
        at Array.map (<anonymous>)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 10.668s
Ran all test suites.
ERROR jest exited with code 1.
error Command failed with exit code 1.

@LinusBorg
Copy link
Member

LinusBorg commented Apr 14, 2018

select full

I can't, that's a preset you saved yourself ;)

However I reproduced the selected options, and can't reproduce this, the tests pass just fine. Can you provide any more information? Like your setup, or a real repository with the failing code? Have you tried re-installing /node_modules?

the error message indicates that the first babel plugin we add with the @vue/babel-preset-app preset exports an invalid property default, which in turn sounds like some error with ES-Module compatibility. But that seems unlikely given that we use require() and module.exports, not ES6 syntax. In a way, this makes sense, we use require() for loading the plugin, and the plugin itself uses export default:

So weh should have to use require().default if babel didn't take care of this. but as it runs fine for me, that seems to be the case generally, yet break for you.

@LinusBorg LinusBorg added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label Apr 14, 2018
@ghost
Copy link
Author

ghost commented Apr 14, 2018

` yves@Yvess-Mac-mini myprojectTEST (master) $ rm -R node_modules
yves@Yvess-Mac-mini myprojectTEST (master) $ yarn install
yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 125.68s

yves@Yvess-Mac-mini myprojectTEST (master) $ yarn test
yarn test v0.27.5
$ vue-cli-service test
PASS tests/unit/HelloWorld.spec.js (5.598s)
HelloWorld.vue
✓ renders props.msg when passed (27ms)

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 11.26s
Ran all test suites.
Done in 21.44s.`

re-building node_modules solved the issue ... I don't understand what happen .. but at leats , it's testing fine .. thanks for your prompt attention to it

@ghost
Copy link
Author

ghost commented Apr 14, 2018

just for info .. I compared the 2 package.json

the only difference I can see , is in the failing one , using @vue/prettier in eslintConfig

"eslintConfig": { "root": true, "extends": [ "plugin:vue/essential", "@vue/prettier" ] },

@liron-navon
Copy link

This is still an issue, is there a solution?

@LinusBorg
Copy link
Member

the OP stated:

re-building node_modules solved the issue

So if you have a similar problem, please open a new issue with a proper reproduction of the problem.

@xeor
Copy link

xeor commented May 14, 2018

I got the same exact same problem as well. Is it back? @Erwin16 does this still work with updated packages?

@xeor
Copy link

xeor commented May 14, 2018

Might be a false positive from my side. I have an app based on quasar that uses a plugin that generates this issue... Might be the quasar .babelrc's fault... My module that I am getting this error from builds fine.

@laurentpayot
Copy link

laurentpayot commented May 15, 2018

This issue started when I switched to Vue CLI 3 beta 10 (with Babel 7 beta). Some other packages (like Cypress webpack preprocessor) were using Babel 6. Manual update to Babel 7 in these packages fixed it.

Different Babel versions do not live together well.

@xeor
Copy link

xeor commented May 20, 2018

The solution for me was switching back to using npm. Doing npm install instead of yarn install solved it..

@spamguy
Copy link

spamguy commented May 25, 2018

Running basic jest unit tests with npm and the latest beta of vue-cli. Same error that others are reporting. I nuked the whole node_modules directory and reinstalled, but with no change.

 FAIL  test/unit/specs/js/auth.spec.js
  ● Test suite failed to run

    Plugin 0 specified in "/Users/spamguy/src/vue-dipl.io/node_modules/@vue/babel-preset-app/index.js" provided an invalid property of "default" (While processing preset: "/Users/spamguy/src/vue-dipl.io/node_modules/@vue/babel-preset-app/index.js")

      at Plugin.init (node_modules/babel-core/lib/transformation/plugin.js:131:13)
      at Function.normalisePlugin (node_modules/babel-core/lib/transformation/file/options/option-manager.js:152:12)
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
          at Array.map (<anonymous>)
      at Function.normalisePlugins (node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
      at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
          at Array.map (<anonymous>)
      at OptionManager.resolvePresets (node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)

@manico
Copy link
Contributor

manico commented May 28, 2018

Have the exact same problem. :(
Here is the reproduction:
https://github.com/chmjs/vuetify-colorizer

Just run npm test

@skhavari
Copy link

Given the repro above, should this be reopened? Also running into this.

@tigerclaw-az
Copy link

@manico can you open a new issue with the repro steps? I believe that's what @LinusBorg asked for after it was closed. i'm also having the same issue, but would be best to start a new issue with your reproduction steps so it can get resolved.

@manico
Copy link
Contributor

manico commented May 30, 2018

It is the same case as the issue described here.
I did nothing special in this repository, so maybe this issue should be reopened.

@zugende
Copy link

zugende commented Jun 8, 2018

EDIT: Went down to node versionn 9.0.0 and it worked. :)

On my local Windows machine the test are passing just fine but on CircleCI I get the following error:

Plugin 0 specified in "/home/circleci/repo/node_modules/@vue/babel-preset-app/index.js" provided an invalid property of "default" (While processing preset: "/home/circleci/repo/node_modules/@vue/babel-preset-app/index.js")

I am using 3.0.0-beta.15 and Node version 9.2.0

@codeHamster9
Copy link

codeHamster9 commented Jun 21, 2018

Same Here :(

 Plugin 0 specified in "../webapp/node_modules/@vue/babel-preset-app/index.js" provided an invalid property of "default" (While processing preset: "../webapp/node_modules/@vue/babel-preset-app/index.js")

      at Plugin.init (node_modules/@vue/cli-plugin-unit-jest/node_modules/babel-core/lib/transformation/plugin.js:131:13)
          at Array.map (<anonymous>)
          at Array.map (<anonymous>)

Node: 10.5 (also tried on 8.9.4)
Vue-cli: 3.0.0-rc3

@christianvoigt
Copy link

same problem here with Vue-cli 3.0.0-rc.3

I am using this in a Monorepo with Lerna and Yarn Workspaces. Deleting all node_modules folders and doing lerna bootstrap did not work.

@LinusBorg
Copy link
Member

This issue is closed, and so far still no reproducion was provided.

Please open a new issue with reproduction

@erichulburd
Copy link

erichulburd commented Jul 7, 2018

I tried a few different things:

const vueApp = (context, options) => {
  const preset = require('@vue/babel-preset-app')(context, options);
  preset.plugins[0] = preset.plugins[0].default;
  return preset;
};

module.exports = {
  presets: [
    vueApp,
    'typescript'
  ]
}

This gave the following error:

 Test suite failed to run

    Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.

      at throwVersionError (node_modules/@babel/plugin-syntax-jsx/node_modules/@babel/helper-plugin-utils/lib/index.js:65:11)
      at Object.assertVersion (node_modules/@babel/plugin-syntax-jsx/node_modules/@babel/helper-plugin-utils/lib/index.js:13:11)
      at api (node_modules/@babel/plugin-syntax-jsx/lib/index.js:19:7)

I am using Node 9.11 and I notice ts-jest depends on babel-core 6.26.3

    "ts-jest": {
      "version": "22.4.6",
      "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-22.4.6.tgz",
      "integrity": "sha512-kYQ6g1G1AU+bOO9rv+SSQXg4WTcni6Wx3AM48iHni0nP1vIuhdNRjKTE9Cxx36Ix/IOV7L85iKu07dgXJzH2pQ==",
      "dev": true,
      "requires": {
        "babel-core": "6.26.3",
        "babel-plugin-istanbul": "4.1.6",
        "babel-plugin-transform-es2015-modules-commonjs": "6.26.2",
        "babel-preset-jest": "22.4.4",
        "cpx": "1.5.0",
        "fs-extra": "6.0.0",
        "jest-config": "22.4.4",
        "lodash": "4.17.10",
        "pkg-dir": "2.0.0",
        "source-map-support": "0.5.6",
        "yargs": "11.1.0"
      },
  // ....

This is my current list of dependencies:

  "dependencies": {
    "register-service-worker": "^1.4.1",
    "vue": "^2.5.16",
    "vue-loader": "^15.2.4",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0-beta.47",
    "@babel/plugin-syntax-jsx": "^7.0.0-beta.52",
    "@babel/preset-typescript": "^7.0.0-beta.52",
    "@types/jest": "^22.2.3",
    "@vue/babel-preset-app": "^3.0.0-rc.3",
    "@vue/cli-plugin-babel": "^3.0.0-beta.15",
    "@vue/cli-plugin-e2e-nightwatch": "^3.0.0-beta.15",
    "@vue/cli-plugin-pwa": "^3.0.0-beta.15",
    "@vue/cli-plugin-typescript": "^3.0.0-beta.15",
    "@vue/cli-plugin-unit-jest": "^3.0.0-beta.15",
    "@vue/cli-service": "^3.0.0-beta.15",
    "@vue/test-utils": "^1.0.0-beta.20",
    "autoprefixer-loader": "^3.2.0",
    "babel-loader": "^7.1.5",
    "babel-preset-es2015": "^6.24.1",
    "css-loader": "^0.28.11",
    "file-loader": "^1.1.11",
    "node-sass": "^4.9.1",
    "sass-loader": "^7.0.3",
    "style-loader": "^0.21.0",
    "ts-jest": "^22.4.6",
    "vue-style-loader": "^4.1.0",
    "vue-template-compiler": "^2.5.16",
    "webpack": "^4.15.1",
    "webpack-cli": "^3.0.8",
    "webpack-dev-server": "^3.1.4",
    "webpack-serve": "^1.0.4"
  },

I tried updating ts-jest to ^23, but a lot of the jest modules depend on babel-register and babel-core 6.26.3.

Will update when I find a solution.

@erichulburd
Copy link

erichulburd commented Jul 7, 2018

Yeah to me it seems like jest-config latest (23.3.x) as of this post, does not work with @babel/etc ^7: https://github.com/facebook/jest/blob/v23.3.0/package.json

So typescript + jest is a no go with the latest vue-cli config.

...

Actually, there is an issue with mocha+chai as well (I am able to replicate this error with the jest option after installing babel-7-jest. Here is a repro:

> vue-cli-service test:unit

/Users/arbolista/Code/tutorials/vue/my-third-app/node_modules/hosted-git-info/index.js:73
      if (!(ex instanceof URIError)) throw ex
                                     ^

TypeError: Cannot read property 'replace' of null
    at /Users/blah/Code/tutorials/vue/my-third-app/node_modules/hosted-git-info/index.js:61:62
    at Array.map (native)
    at fromUrl (/Users/blah/Code/tutorials/vue/my-third-app/node_modules/hosted-git-info/index.js:45:39)
    at Function.module.exports.fromUrl (/Users/arbolista/Code/tutorials/vue/my-third-app/node_modules/hosted-git-info/index.js:32:18)
    at Object.<anonymous> (/Users/blah/Code/tutorials/vue/my-third-app/node_modules/normalize-package-data/lib/fixer.js:150:36)
    at Array.forEach (native)
    at Object.<anonymous> (/Users/blah/Code/tutorials/vue/my-third-app/node_modules/normalize-package-data/lib/fixer.js:144:31)
    at Array.forEach (native)
    at Object.fixDependencies (/Users/blah/Code/tutorials/vue/my-third-app/node_modules/normalize-package-data/lib/fixer.js:137:41)
    at /Users/blah/Code/tutorials/vue/my-third-app/node_modules/normalize-package-data/lib/normalize.js:32:38

https://github.com/erichulburd/vue-cli-typescript-test-issues

@haverchuck
Copy link

haverchuck commented Sep 10, 2018

I was also facing the same issue. I corrected it by simply nuking my node_modules and package.json, and then updating the devDependencies with the latest values spit out in a fresh project created via CLI... these being:

    "@vue/cli-plugin-babel": "^3.0.1",
    "@vue/cli-plugin-eslint": "^3.0.1",
    "@vue/cli-plugin-unit-jest": "^3.0.1",
    "@vue/cli-service": "^3.0.1",
    "@vue/eslint-config-airbnb": "^3.0.1",
    "@vue/test-utils": "^1.0.0-beta.20",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "^23.0.1",
    "vue-template-compiler": "^2.5.17"

Worked like a charm after that.

@zdravkov
Copy link

zdravkov commented Oct 8, 2018

@haverchuck - thanks for sharing :) - "babel-core": "7.0.0-bridge.0" was not included by default at my side and adding it manually solved the issue.

@Max-0n
Copy link

Max-0n commented Oct 21, 2019

remove: babel-core
and install: @babel/core

It works.

@znicholasbrown
Copy link

Nice @Max-0n, that worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction This issue is missing a minimal runnable reproduction, provided by the author
Projects
None yet
Development

No branches or pull requests