wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
758 stars 45 forks source link

Runtime error: ReferenceError: $_$wp is not defined #1782

Closed majkelch closed 6 years ago

majkelch commented 6 years ago

Wallaby is failing with following error:

console.log:   ● Test suite failed to run

    ReferenceError: $_$wp is not defined
      at Object.<anonymous> (../../.WebStorm2018.2/system/wallaby/projects/5c96a4b003c97a22/instrumented/test/unit/setup.js:2:1)
      at Runtime.d._wallabyReplaced.c.requireModule (../../.WebStorm2018.2/system/wallaby/wallaby/runners/node/jest@0.4.3/initializer.js:14:21874)

I removed and reinstalled node_modules with npm and yarn but it error still occurs.

wallaby.js core v1.0.610 jest 23.3.0 jest-cli 23.3.0 vue 2.5.17

Wallaby.js configuration file

module.exports = function (wallaby) {
  return {
    name: 'project',
    files: [
      'src/*',
      'src/components/**/*',
      'src/config/**/*',
      'src/filters/**/*',
      'src/i18n/**/*',
      'src/mixins/**/*',
      'src/routes/**/*',
      'src/services/**/*',
      'src/store/**/*',
      'test/unit/*.js',
      'static/pkg.json',
      'package.json'
    ],

    tests: ['test/**/*.spec.js'],

    env: {
      type: 'node',
      runner: 'node'
    },

    compilers: {
      '**/*.js': wallaby.compilers.babel(),
      '**/*.vue': require('wallaby-vue-compiler')(wallaby.compilers.babel({}))
    },

    preprocessors: {
      '**/*.vue': file => require('vue-jest').process(file.content, file.path)
    },

    setup: function (wallaby) {
      const jestConfig = require('./package').jest || require('./test/unit/jest.conf')
      jestConfig.transform = {};
      wallaby.testFramework.configure(jestConfig)
    },

    testFramework: 'jest',

    debug: true,
    reportConsoleErrorAsError: true,
    delays: {
      run: 2000
    }
  }
}

Code editor or IDE name and version

WebStorm 2018.2 Build #WS-182.3684.70, built on July 20, 2018 JRE: 1.8.0_152-release-1248-b8 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

OS name and version

Windows 10 10.0

ArtemGovorov commented 6 years ago

I have just generated a new project with vue-cli 2.x (from your Wallaby config it looks like you're using it), updated Jest to 23.3.0, added your Wallaby config and the sample is working for me. I have created this sample repo with the code.

Could you please try the repo to see if it's working for you? If it is working, please share your package.json dependenciesanddevDependenciessections and youryarn.lock/package-lock.json` file.

majkelch commented 6 years ago

package-lock.zip

I've tried your configuration and it works... unfortunately for me. So this is my package.json

{
"dependencies": {
    "axios": "^0.18.0",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-polyfill": "^6.26.0",
    "global": "^4.3.2",
    "highcharts": "^6.0.7",
    "i18next": "^10.6.0",
    "moment": "^2.20.1",
    "nouislider": "^10.1.0",
    "ramda": "^0.25.0",
    "vue": "^2.5.16",
    "vue-cli": "^2.9.6",
    "vue-highcharts": "0.0.10",
    "vue-nav-tabs": "^0.5.6",
    "vue-router": "^3.0.1",
    "vue-svg-custom-icon": "^1.0.6",
    "vuelidate": "^0.6.1",
    "vuetify": "^1.0.19",
    "vuex": "^3.0.1",
    "wallaby-vue-compiler": "^1.0.3",
    "wnumb": "^1.1.0"
  },
  "devDependencies": {
    "@vue/test-utils": "^1.0.0-beta.16",
    "autoprefixer": "^8.2.0",
    "babel-core": "^6.22.1",
    "babel-eslint": "^8.2.1",
    "babel-jest": "^23.0.0",
    "babel-loader": "^7.1.4",
    "babel-plugin-dynamic-import-node": "^1.2.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "babel-register": "^6.22.0",
    "chalk": "^2.3.1",
    "compression-webpack-plugin": "^1.1.11",
    "copy-webpack-plugin": "^4.5.1",
    "create-svg-sprite": "^1.0.4",
    "cross-env": "^5.1.4",
    "css-loader": "^0.28.11",
    "eslint": "^4.19.1",
    "eslint-config-standard": "^11.0.0",
    "eslint-friendly-formatter": "^4.0.0",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-html": "^4.0.2",
    "eslint-plugin-import": "^2.10.0",
    "eslint-plugin-node": "^6.0.0",
    "eslint-plugin-promise": "^3.7.0",
    "eslint-plugin-standard": "^3.0.1",
    "eventsource-polyfill": "^0.9.6",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.4",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "git-revision-webpack-plugin": "^2.5.1",
    "html-webpack-plugin": "^3.1.0",
    "jest": "23.3.0",
    "jest-cli": "23.3.0",
    "jest-bamboo-reporter": "^1.2.0",
    "jest-serializer-vue": "^1.0.0",
    "jsdoc": "^3.5.5",
    "minami": "^1.2.3",
    "ncp": "^2.0.0",
    "node-notifier": "^5.2.1",
    "node-sass": "^4.8.3",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^2.0.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.1.0",
    "postcss-loader": "^2.1.3",
    "rimraf": "^2.6.2",
    "sass-loader": "^6.0.6",
    "semver": "^5.5.0",
    "shelljs": "^0.8.1",
    "url-loader": "^1.0.1",
    "vue-jest": "^2.6.0",
    "vue-loader": "^14.2.2",
    "vue-style-loader": "^4.1.0",
    "vue-template-compiler": "^2.5.16",
    "webpack": "^3.11.0",
    "webpack-bundle-analyzer": "^2.10.0",
    "webpack-dev-server": "^2.11.2",
    "webpack-merge": "^4.1.0"
  },
  "engines": {
    "node": ">= 6.9.1",
    "npm": ">= 3.10.8"
  },
  "browserslist": [
    "last 2 versions",
    "not safari <= 9",
    "not ie <= 10"
  ]
}
ArtemGovorov commented 6 years ago

Thanks. Have added your package.json and package-lock.json files as is to the sample repo, deleted node_modules, ran npm i, and everything is still working for me.

Could you please get the latest version of the sample repo and try if Wallaby is working for you? If so, could you please try finding what's missing in the repo to reproduce the issue? Or maybe create a sample repo based off your real project (no source code is required, the failure seems to occur prior to any tests running, during running the setup file test/unit/setup.js).

majkelch commented 6 years ago

I can confirm, that your updated repo is working fine. Mine is also working fine now. What I did is I reinstalled some dependencies with another versions. So I cannot tell for sure what helped here.

So, thank you very much for your time.

ArtemGovorov commented 6 years ago

Awesome, thanks for the update!