I'm just trying to test a simple component. I inherited a project and it was set up with Vue CLI 2 and it looks very boilerplatey. My issue is I'm trying to unit test anything I devote to the project. However, I'm having issues with the vuex store coming up as undefined. It's preventing me from testing and I haven't figured it out yet.
I googled around and found multiple things including this. Vue.js and vuex: this.$store is undefined
This is the error message I'm receiving
> cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
07 08 2019 14:52:06.948:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/07 08 2019 14:52:06.958:INFO [launcher]: Launching browser ChromeHeadless with unlimited
concurrency
07 08 2019 14:52:07.006:INFO [launcher]: Starting browser ChromeHeadless
07 08 2019 14:52:17.675:INFO [HeadlessChrome 75.0.3770 (Windows 10.0.0)]: Connected on socket KXXgp_cAT4JbkbufAAAA with id 2108708
HeadlessChrome 75.0.3770 (Windows 10.0.0) WARN LOG: '[vue-router] Duplicate named routes
definition: { name: "load-balancing", path: "/networking/load-balancing/:ServiceRequestId/edit" }'
07 08 2019 14:52:20.798:WARN [web-server]: 404: /static/img/oops.png
HeadlessChrome 75.0.3770 (Windows 10.0.0) WARN LOG: '[vue-router] Duplicate named routes
definition: { name: "resource-groups", path: "/portal/resource-groups/:ResourceGroupId" }'
HeadlessChrome 75.0.3770 (Windows 10.0.0) WARN LOG: '[vue-router] Duplicate named routes
definition: { name: "manage-service-offerings", path: "/portal/admin/service-offerings/new" }'
HeadlessChrome 75.0.3770 (Windows 10.0.0) WARN LOG: '[vue-router] Duplicate named routes
definition: { name: "manage-service-offerings", path: "/portal/admin/service-offerings/:Id" }'
HeadlessChrome 75.0.3770 (Windows 10.0.0) ERROR LOG: '[Vue warn]: Cannot find element: #app'
HeadlessChrome 75.0.3770 (Windows 10.0.0) WARN LOG: '[Vuetify] Unable to locate target [data-app]
found in
---> <VDialog>
<VApp>
<App> at src/App.vue
<Root>'
HeadlessChrome 75.0.3770 (Windows 10.0.0) WARN LOG: '[Vuetify] Unable to locate target [data-app]
found in
---> <VDialog>
<VApp>
<App> at src/App.vue
<Root>'
ERROR LOG: '[Vuetify] Image load failed
src: /static/img/oops.png
found in
---> <VImg>
<VCard>
<ThemeProvider>
<VDialog>
<VApp>
<App> at src/App.vue
<Root>'
ERROR LOG: '[Vue warn]: Error in config.errorHandler: "TypeError: Cannot read property 'state' of undefined"'
ERROR LOG: TypeError{}
ERROR LOG: '[Vue warn]: Error in render: "TypeError: Cannot read property 'state' of undefined"
found in
---> <UserDropdownMenu> at src/components/common/UserDropDownMenu.vue
<Root>'
ERROR LOG: TypeError{}
User.vue
× should have a default value of false for user-menu
TypeError: Cannot read property 'state' of undefined
at VueComponent.mappedState (webpack:///node_modules/vuex/dist/vuex.esm.js:791:0 <- index.js:5858:31)
at Watcher.get (webpack:///node_modules/vue/dist/vue.esm.js:3142:0 <- index.js:10010:25)
at Watcher.evaluate (webpack:///node_modules/vue/dist/vue.esm.js:3249:0 <- index.js:10117:21)
at VueComponent.computedGetter [as User] (webpack:///node_modules/vue/dist/vue.esm.js:3507:0 <- index.js:10375:17)
at VueComponent.userPhoto (webpack:///src/components/common/UserDropDownMenu.vue:35:0 <- index.js:25280:49)
at Watcher.get (webpack:///node_modules/vue/dist/vue.esm.js:3142:0 <- index.js:10010:25)
at Watcher.evaluate (webpack:///node_modules/vue/dist/vue.esm.js:3249:0 <- index.js:10117:21)
at VueComponent.computedGetter [as userPhoto] (webpack:///node_modules/vue/dist/vue.esm.js:3507:0 <- index.js:10375:17)
at Object.get (webpack:///node_modules/vue/dist/vue.esm.js:1943:0 <- index.js:8811:20)
at Proxy.render (webpack:///src/components/common/UserDropDownMenu.vue?bfff:19:26 <- index.js:85974:37)
HeadlessChrome 75.0.3770 (Windows 10.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.746 secs / 0.01 secs)
I just want to know why store isn't rendering correctly
Here is the simple test that I wrote
import {expect} from 'chai'
import {shallowMount} from '#vue/test-utils'
import UserDropDownMenu from '#/components/common/UserDropDownMenu.vue'
describe('User.vue', () => {
it('should have a default value of false for user-menu', () => {
const wrapper = shallowMount(UserDropDownMenu)
const vm = wrapper.vm
const data = vm.$data
expect(data.UserDropDownMenu).to.equal(false)
})
})
Related
Uncaught promise when registering a custom element using the latest
sapper, svelte, nodeJS, and rollup stack using the following
statements.
REPL example: https://svelte.dev/repl/489ee8acd10848b0bb1feb2535bd6cc5?version=3.16.5 created locally
<svelte:options tag="parlax-background" />
& rollup.config.js
export default {
client: {
input: config.client.input(),
output: config.client.output(),
plugins: [
replace({...})
svelte({
dev: !production,
customElement: true,
// and tried also with customElement: { tag: "my-element"}
hydratable: true,
emitCss: true
I want to mention that I had tested on a fresh project
Logs
[Client Side]
=> Uncaught (in promise) TypeError: Illegal constructor
at new SvelteElement (index.mjs:1381)
[Server Side]
=> The 'tag' option is used when generating a custom element. Did you forget the 'customElement: true' compile option?
44: <svelte:options tag="my-element" />
1. When I registering [ **customElement: true ] in the config i get**
2. If I do not register my element in the config I do not get any error, but neither my element is registered :(
Ref: https://github.com/sveltejs/svelte/issues/4132
As described in the referenced GitHub issue, once you configure the Svelte compiler with customElements: true, you're expected to provide an element tag for all your components (using <svelte:options tag="my-component"/>.
In your REPL's example, this would mean updating App.svelte with e.g. <svelte:options tag="my-app"/>
When you now run the app, you should not see the error in the console anymore, but a working app.
The vuejs common components which I created as a web-component and uploaded to npm doesn't work when I installed it to a different file. I think it's because of lazy-loading. I tried searching some fixes but I can't find that fixed my problem.
On chrome and firefox error images are provided
I am using this code on importing the components inside web-components.
components: {
'data-description-c': () => import(/* webpackChunkName: "data-description-c" */ './myPage/DataDescriptionC.vue'),
'data-count-c': () => import(/* webpackChunkName: "data-count-c" */'./myPage/DataCountC.vue')
},
Error on chrome:
[Vue warn]: Failed to resolve async component: function data_description_c() {
return __webpack_require__.e(/* import() | data-description-c */ 3).then(__webpack_require__.bind(null, "dffc"));
}
Reason: Error: Loading chunk 3 failed.
(missing: http://localhost:8080/idist-components.common.data-description-c.js)
[Vue warn]: Failed to resolve async component: function data_count_c() {
return __webpack_require__.e(/* import() | data-count-c */ 2).then(__webpack_require__.bind(null, "755f"));
}
Reason: Error: Loading chunk 2 failed.
(missing: http://localhost:8080/idist-components.common.data-count-c.js)
Error on firefox:
[Vue warn]: Failed to resolve async component: function data_description_c() {
return __webpack_require__.e(/* import() | data-description-c */ 3).then(__webpack_require__.bind(null, "dffc"));
}
Reason: Error: Loading chunk 3 failed.
(missing: http://localhost:8080/idist-components.common.data-description-c.js)
[Vue warn]: Failed to resolve async component: function data_count_c() {
return __webpack_require__.e(/* import() | data-count-c */ 2).then(__webpack_require__.bind(null, "755f"));
}
Reason: Error: Loading chunk 2 failed.
(missing: http://localhost:8080/idist-components.common.data-count-c.js)
My web app reads local files using a custom ReadableStream (in-order that I won't need to have a max file size that the platform supports) and it works great, both for correctly formatted files and error files. My app is built using React-Redux-Saga.
I'm now attempting to add limited e2e tests to my code to test the state management. I'm testing that when sending redux actions the state updates correctly. I'm testing the saga's using the package redux-saga-tester.
While running the jest client tests that read local files using the ReadableStream I built, I got an error ReferenceError: ReadableStream is not defined. What I understood is that the jsdom environment that jest uses is missing the ReadableStream implementation. I than added the web-streams-polyfill package to polyfill the ReadableStream class.
Now the validate file test is passing as in the browser:
test('Select and validate log file', async () => {
const testFile = testFileBuilder.valid();
storeTester.dispatch(fileSelected(testFile));
await storeTester.waitFor(FILE_VALIDATED);
const state = storeTester.getState().file;
expect(state.fileValidated).toBeTruthy();
});
My problem is that when I run a second validation test with an invalid file the test passes but prints an error to the console.
The test:
test('Select an invalid file - JSON error', async () => {
const testFile = testFileBuilder.errorJSON();
storeTester.dispatch(fileSelected(testFile));
await storeTester.waitFor(FILE_ERROR);
const state = storeTester.getState().file;
expect(state.fileValidated).toBeFalsy();
expect(state.fileError).toBeTruthy();
});
The error that is printed after the test completes successfully:
e.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Error: connect ECONNREFUSED 127.0.0.1:80
at Object.dispatchError (/home/noams/dev/web/visual-log-viewer/client/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
at Request.client.on.err (/home/noams/dev/web/visual-log-viewer/client/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:676:20)
at Request.emit (events.js:194:15)
at Request.onRequestError (/home/noams/dev/web/visual-log-viewer/client/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:189:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19) undefined
Any subsequent file validation tests fail.
I'd appreciate any advice of how to tackle this issue.
enter image description here
enter image description here
INFO Starting development server...
95% emitting CopyPlugin ERROR Failed to compile with 1 errors12:29:34
error in ./src/router.js
Module parse failed: Unexpected token (17:13)
You may need an appropriate loader to handle this file type.
| // which is lazy-loaded when the route is visited.
| component: function component() {
> return import(
| /* webpackChunkName: "about" */
| './views/About.vue');
# ./src/main.js 6:0-30 10:10-16
# multi (webpack)-dev-server/client?http://192.168.75.129:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
{ [Error: EACCES: permission denied, open '/home/dollarkiller/demo/testdemo/node_modules/.stats-serve.json']
errno: -13,
code: 'EACCES',
syscall: 'open',
path:
'/home/dollarkiller/demo/testdemo/node_modules/.stats-serve.json' }
My operating environment:
node v10.15.2
npm 6.6.0
vue cli 3.3.0
vue create verdemo
Bable Router Vuex stylus eslint
Report errors
Default default deployment does not report errors
NPM "create vue project" (with router) - server not starting
Here is the answer you want
I have a puppeteer script I run to reboot my modem. It has worked for I guess about a year with no problem. 5 days ago it stopped working. I was looking into it and realized that I am getting errors I didn't used to get when running it and the script fails. The thing is I didn't change anything. As far as I can see, the HTML hasn't changed either yet it is failing. So I wonder if there is a bug in chromium or puppeteer or if it handles things differently somehow?
Here's a codepen with https://codepen.io/michaelbierman/pen/qQjdYR
HTML page
puppeteer script
errors
ERROR OUTPUT
Thursday 11/15/2018 11:14:04, Login...
Unhandled Rejection at: Promise (new page) Promise {
Error: No node found for selector: #id_username
at assert (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:278:11)
at Frame.type (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/FrameManager.js:771:5)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
-- ASYNC --
at Frame. (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:144:27)
at Page.type (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/Page.js:971:29)
at /Users/bierman/Documents/Applications/bin/arris/arristest.js:49:13
at
at process._tickCallback (internal/process/next_tick.js:188:7) } reason: Error: No node found for selector: #id_username
at assert (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:278:11)
at Frame.type (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/FrameManager.js:771:5)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
-- ASYNC --
at Frame. (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:144:27)
at Page.type (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/Page.js:971:29)
at /Users/bierman/Documents/Applications/bin/arris/arristest.js:49:13
at
at process._tickCallback (internal/process/next_tick.js:188:7)
/Users/bierman/Documents/Applications/bin/arris/arristest.js:29
browser.close();
^
ReferenceError: browser is not defined
at process.on (/Users/bierman/Documents/Applications/bin/arris/arristest.js:29:2)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emitPendingUnhandledRejections (internal/process/promises.js:108:22)
at process._tickCallback (internal/process/next_tick.js:189:7)
BigMac:bin michael$ /usr/local/bin/node /Users/bierman/Documents/Applications/bin/arris/arristest.js
Thursday 11/15/2018 11:20:29, Login...
Thursday 11/15/2018 11:20:36, Go to home...
Unhandled Rejection at: Promise (new page) Promise {
Error: No node found for selector: #alertExitButton
at assert (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:278:11)
at Frame.click (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/FrameManager.js:704:5)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
-- ASYNC --
at Frame. (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:144:27)
at Page.click (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/Page.js:932:29)
at /Users/bierman/Documents/Applications/bin/arris/arristest.js:62:13
at
at process._tickCallback (internal/process/next_tick.js:188:7) } reason: Error: No node found for selector: #alertExitButton
at assert (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:278:11)
at Frame.click (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/FrameManager.js:704:5)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
-- ASYNC --
at Frame. (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/helper.js:144:27)
at Page.click (/Users/bierman/Documents/Applications/bin/arris/node_modules/puppeteer/lib/Page.js:932:29)
at /Users/bierman/Documents/Applications/bin/arris/arristest.js:62:13
at
at process._tickCallback (internal/process/next_tick.js:188:7)
/Users/bierman/Documents/Applications/bin/arris/arristest.js:29
browser.close();
^
ReferenceError: browser is not defined
at process.on (/Users/bierman/Documents/Applications/bin/arris/arristest.js:29:2)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emitPendingUnhandledRejections (internal/process/promises.js:108:22)
at process._tickCallback (internal/process/next_tick.js:189:7)
Try this:
npm uninstall chromium
npm uninstall puppeteer
npm i chromium#1
npm i puppeteer