Error when running tests of vue-components importing ipcRenderer
See original GitHub issueDescribe 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
"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:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Latest v10.x variant, and I used the latest version of yarn, rather than npm.
ipcRenderer
noticpRenderer