question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Cannot convert undefined or null to object" at installQuasar

See original GitHub issue

Application uses vue3 + ts + quasar and jest for testing. Getting error “Cannot convert undefined or null to object” at installQuasar when doing localVue.use(Quasar) or plugins: [Quasar] in test file. The config files are as mentioned below

package.json -

"dependencies": {
    "@quasar/extras": "^1.11.4",
    "@types/vue-i18n": "^7.0.0",
    "axios": "^0.20.0",
    "core-js": "^3.6.5",
    "d3": "^6.2.0",
    "echarts": "^5.1.2",
    "lodash": "~4.17.20",
    "qs": "^6.9.6",
    "quasar": "^2.2.1",
    "rison": "^0.1.1",
    "vue": "3.0.6",
    "vue-i18n": "^9.1.5",
    "vue-router": "^4.0.12"
  },
  "devDependencies": {
    "@types/d3": "^5.16.3",
    "@types/echarts": "^4.9.8",
    "@types/lodash": "^4.14.160",
    "@types/node": "^14.17.32",
    "@types/rison": "0.0.6",
    "@types/webpack-env": "^1.16.3",
    "@typescript-eslint/eslint-plugin": "^5.3.1",
    "@typescript-eslint/parser": "^5.3.1",
    "@vue/cli-plugin-babel": "^4.5.14",
    "@vue/cli-plugin-eslint": "^4.5.14",
    "@vue/cli-plugin-router": "^4.5.14",
    "@vue/cli-plugin-typescript": "^4.5.14",
    "@vue/cli-plugin-unit-jest": "^4.5.15",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "3.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/eslint-config-typescript": "^9.0.1",
    "@vue/test-utils": "^2.0.0-0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-plugin-transform-imports": "2.0.0",
    "eslint": "^7.0.0",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-vue": "^7.0.0",
    "node-sass": "4.13.0",
    "prettier": "^1.19.1",
    "sass-loader": "^8.0.2",
    "typescript": "~3.9.3",
    "vue-cli-plugin-quasar": "~4.0.4",
    "vue-jest": "^5.0.0-0"
  }

jest.config.js -

module.exports = {
  preset: "@vue/cli-plugin-unit-jest/presets/typescript-and-babel",
  transformIgnorePatterns: ["node_modules/(?!(quasar|echarts|zrender)/)"],
  transform: {
    // process *.vue files with vue-jest
    '^.+\\.vue$': require.resolve('vue-jest'),
  }
};

babel.config.js -

module.exports = {
  presets: ["@vue/cli-plugin-babel/preset"]
};

test file assets.spec.ts-

import { Quasar } from "quasar";
import { createApp } from "vue";

const localVue = createApp({});
localVue.use(Quasar);

Error

 Test suite failed to run

    TypeError: Cannot convert undefined or null to object
        at Function.assign (<anonymous>)

      4 |
      5 | const localVue = createApp({});
    > 6 | localVue.use(Quasar);
        |          ^
      7 |

      at installQuasar (node_modules/quasar/dist/quasar.cjs.prod.js:6:13539)
      at Object.install (node_modules/quasar/dist/quasar.cjs.prod.js:6:468377)
      at Object.use (node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:2962:28)
      at Object.<anonymous> (tests/unit/assets.spec.ts:6:10)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

Getting an error “Cannot convert undefined or null to object ...
The better answer because the typeof solves the problem of the data being "truthy" but not an object, in one go. In TypeScript...
Read more >
jest typeerror: cannot convert undefined or null to object
From the command line npm run test results in the error: TypeError: Cannot convert undefined or null to object at Function.keys () at...
Read more >
Cannot convert undefined or null to object - YouTube
JavaScript : How to resolve TypeError: Cannot convert undefined or null to object [ Gift : Animated Search Engine ...
Read more >
Configuring quasar.config.js
You'll notice that /quasar.config.js exports a function that takes a ctx (context) parameter and returns an Object. This allows you to dynamically change ......
Read more >
Cannot convert undefined or null to object : r/learnjavascript
For some reason, when I fetch data and console.log it, it displays the data. But when I set it to a state, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found