TypeError: Cannot create proxy with a non-object as target or handler when running 'yarn test:unit'
bruceauyeung opened this issue · 3 comments
using vue-cli
and vue-cli-plugin-electron-builder
to mange and build my app.
error occurs when running yarn test:unit
# yarn test:unit
yarn run v1.19.0
$ vue-cli-service test:unit
FAIL tests/unit/refUtils.spec.ts
● Test suite failed to runTypeError: Cannot create proxy with a non-object as target or handler
1 | import WorkbenchTab from '@/components/Workbench/workbenchTab';
2 | import { remote } from 'electron';
> 3 | import { is } from 'electron-util';
| ^
4 |
5 | import { SharedObjectKey } from '@/sharedObjects/sharedObjectKey';
6 |at Object.<anonymous> (node_modules/electron-util/source/api.js:4:18) at Object.<anonymous> (node_modules/electron-util/index.js:8:13) at Object.<anonymous> (src/sharedObjects/sharedObjects.ts:3:1) at Object.<anonymous> (src/logger/index.ts:3:1) at Object.<anonymous> (src/commons/lang/array.ts:1:1) at Object.<anonymous> (src/bindings/types.ts:3:1) at Object.<anonymous> (tests/unit/refUtils.spec.ts:1:1)
electron-util: 0.13.0
It means electron
is not available:
Line 4 in 0d00b46
It's expected that Electron is available. There's not much we can do about that. You probably need to fix your test config.
@sindresorhus does this mean electron-util
can only work in one of electron processes ?
Yes, it's meant for Electron apps.
If you're testing your Electron app, you could use https://github.com/electron-userland/spectron
There are a few Node.js-only APIs though: https://github.com/sindresorhus/electron-util#nodejs-api