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.

Error when running tests of vue-components importing ipcRenderer

See original GitHub issue

Describe the bug When you run "test:unit": "vue-cli-service test:unit" and you have a vue component that imports ipcRenderer, import { ipcRenderer } from 'electron';, there is an error, screenshot below.

To Reproduce Create a project using the vue-cli and add this plugin to the project. Then add import { ipcRenderer } from 'electron'; to HelloWorld.vue. Then run the test script.

Expected behavior I expect to be able to test vue components using the ipcRenderer.

Screenshots image

"dependencies": {
    "chai-as-promised": "^7.1.1",
    "core-js": "^3.4.3",
    "vue": "^2.6.10"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-unit-mocha": "^4.1.0",
    "@vue/cli-service": "^4.1.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "chai": "^4.1.2",
    "electron": "^6.0.0",
    "vue-cli-plugin-electron-builder": "^1.4.3",
    "vue-template-compiler": "^2.6.10"
  }
import { expect } from 'chai'
import { shallowMount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'

describe('HelloWorld.vue', () => {
  it('renders props.msg when passed', () => {
    const msg = 'new message'
    const wrapper = shallowMount(HelloWorld, {
      propsData: { msg }
    })
    expect(wrapper.text()).to.include(msg)
  })
})

Environment

  • OS and version: Ubuntu 18.04
  • node version: 12.13.1
  • npm version: 6.12.1

EDIT: Fixed typo

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nklaymancommented, Dec 20, 2019

Latest v10.x variant, and I used the latest version of yarn, rather than npm.

1reaction
Muse-1996commented, Dec 20, 2019

ipcRenderer not icpRenderer

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import ipcRenderer in vue.js ? __dirname is not defined
Updated Answer - Nodeintegration disabled and contextIsolation enabled. In order to use the ipcRenderer with Vue CLI plugin Electron Builder ...
Read more >
[Solved]-Import bluebird on quasar-Vue.js - appsloveworld.com
Coding example for the question Import bluebird on quasar-Vue.js. ... src/boot/promise.js export default () => { import { Promise } from 'bluebird'; ...
Read more >
Electron Preload Script - Quasar Framework
If you import anything from node_modules, then make sure that the package is specified in /package.json > “dependencies” and NOT in “devDependencies”. Security ......
Read more >
How to import ipcRenderer in Renderer Process' Component
So I quickly created a sample web app using create-react-app and started updating the UI to suit my sample application. It was all...
Read more >
how can I use electron apis | Quasar Framework Community
But when I use import {remote} from “electron”, error pop up for not ... the web app and in the Electron app (both...
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