TypeError: webdriverio_1.default is not a function - Percy2 and WebdriverIO7 - webdriver-io

I get this error using webdriverio v7 and latest Percy for visual testing:
[0-2] Error in "0: I can see page "Product Detail Page of the last product""
TypeError: webdriverio_1.default is not a function
at C:\WORK\AutomationPlayground\domain-work\webdriverio-tutorial-demo\src\step_definitions\visual\visual-steps.ts:7:45
at Browser.call (C:\WORK\AutomationPlayground\domain-work\webdriverio-tutorial-demo\node_modules\webdriverio\build\commands\browser\call.js:43:16)
at Browser.runCommandWithHooks (C:\WORK\AutomationPlayground\domain-work\webdriverio-tutorial-demo\node_modules\#wdio\sync\build\wrapCommand.js:105:34)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at Browser.runCommandWithHooks (C:\WORK\AutomationPlayground\domain-work\webdriverio-tutorial-demo\node_modules\#wdio\sync\build\wrapCommand.js:100:24)
at Browser.wrapCommandFn (C:\WORK\AutomationPlayground\domain-work\webdriverio-tutorial-demo\node_modules\#wdio\sync\build\wrapCommand.js:67:44)
at World.<anonymous> (C:\WORK\AutomationPlayground\domain-work\webdriverio-tutorial-demo\src\step_definitions\visual\visual-steps.ts:7:13)
at World.executeSync (C:\WORK\AutomationPlayground\domain-work\webdriverio-tutorial-demo\node_modules\#wdio\sync\build\index.js:38:22)
at C:\WORK\AutomationPlayground\domain-work\webdriverio-tutorial-demo\node_modules\#wdio\sync\build\index.js:69:68
It doesn't even get to percy, so there is no screenshot there.
All I do in the code is taking screenshot of the page:
import percySnapshot from '#percy/webdriverio';
import { Then } from '#cucumber/cucumber';
Then(/^I can see page "([^"]*)"$/, (name: string) => {
browser.waitForPageToLoad();
browser.call(() => percySnapshot(name));
});
This is my package.json file:
"devDependencies": {
"#cucumber/cucumber": "^7.1.0",
"#percy/cli": "^1.0.0-beta.48",
"#percy/webdriverio": "^2.0.0",
"#types/chai": "^4.2.16",
"#types/node": "^14.14.41",
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"allure-commandline": "^2.13.8",
"app-root-path": "^3.0.0",
"chai": "^4.3.4",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^6.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.2.4",
"webdriverio": "^7.4.6"
},
"dependencies": {
"#wdio/allure-reporter": "^7.4.2",
"#wdio/cli": "^7.4.6",
"#wdio/cucumber-framework": "^7.4.6",
"#wdio/local-runner": "^7.4.6",
"#wdio/selenium-standalone-service": "^7.4.2",
"#wdio/spec-reporter": "^7.4.3",
"#wdio/sync": "^7.4.6"
}
Note:
This used to work prior upgrading to webdriverIO v7 and percy v2.
Anybody has an idea how to solve it?
Thanks!

Discussed here github
I needed to add in tsconfig.json file these options:
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,

Related

Error Message in HTML DOM ("JSX.IntrinsicElements" not exists. VueDX/TS)

i work on a new project and my vscode look like this:
Unfortunately, nothing helped at the moment.
uninstall Volar (Vue 3)
add in jsconfig.json following lines:
"allowJs": false,
"checkJs": false
In this Project we use nuxt and vuetify.
"dependencies": {
"#nuxtjs/axios": "^5.13.6",
"#nuxtjs/proxy": "^2.1.0",
"core-js": "^3.15.1",
"json-server": "^0.17.0",
"nuxt": "^2.15.7",
"vue-beautiful-chat": "^2.5.0",
"vue-tree-list": "^1.5.0",
"vuelidate": "^0.7.7",
"vuetify": "^2.5.5"
},
"devDependencies": {
"#nuxt/postcss8": "^1.1.3",
"#nuxtjs/vuetify": "^1.12.1",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.14",
"prettier": "2.5.1",
"tailwindcss": "^3.1.2"
}
This is the error message:

Vue-jest Failed to collect coverage from vue file

Hello I'm new to vue and jest. I added jest to already existing vue project.
And I want get test coverage result from .js and .vue file.
But. It dosen't go well.
When I try run
vue-cli-service test:unit
Return below Error
Failed to collect coverage from D:\work\project\src\components\service\sidebar\partials\menu.vue
ERROR: Falsy value found in plugins
Here is my config files
.babelrc
{
"presets": [
["env"], "stage-2"
],
"plugins": ["dynamic-import-node"],
"comments": true
}
jset.config.js
module.exports = {
preset: '#vue/cli-plugin-unit-jest/presets/no-babel',
moduleNameMapper: {
'^#/(.*)$': '<rootDir>/src/$1'
},
collectCoverage :true,
moduleFileExtensions: [
'js',
'json',
'vue'
],
transform: {
// process `*.vue` files with `vue-jest`
".*\\.(vue)$": "vue-jest",
// process js with `babel-jest`
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
},
collectCoverageFrom: [
'**/*.{js,vue}',
'!**/plugins/**',
'!src/main.js',
'!src/router/index.js',
'!**/node_modules/**'
]
}
package.json
{
"name": "web-application",
"version": "1.0.0",
"private": true,
"description": "web-application",
"author": "John",
"scripts": {
...
"test:unit": "vue-cli-service test:unit",
},
"dependencies": {
...
"copy-webpack-plugin": "^4.6.0",
"dotenv": "^8.1.0",
"element-ui": "^2.10.0",
"eslint-plugin-vue": "^5.2.3",
"fs": "0.0.1-security",
"log4js": "^5.0.0",
"lottie-web": "^5.5.5",
"pm2": "^3.5.1",
"recordrtc": "^5.5.8",
"request": "^2.88.0",
"sweetalert2": "^8.13.0",
"vue": "^2.6.10",
"vue-croppie": "^1.3.13",
"vue-drag-select": "^0.1.5",
"vue-izitoast": "^1.2.1",
"vue-moment": "^4.0.0",
"vue-raven": "^1.0.3",
"vue-router": "^3.1.3",
"vue-tilt.js": "^1.0.2",
"vue-toasted": "^1.1.27",
"vue2-scrollbar": "0.0.3",
"vuex": "^3.1.1"
},
"devDependencies": {
"#babel/preset-env": "^7.4.5",
"#vue/cli-plugin-unit-jest": "^4.2.3",
"#vue/cli-service": "^4.2.3",
"#vue/test-utils": "^1.0.0-beta.31",
"babel-core": "^6.25.0",
"babel-eslint": "^8.2.2",
"babel-jest": "^25.2.3",
"babel-loader": "^7.1.1",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-2": "^6.24.1",
"clean-webpack-plugin": "^0.1.19",
"crypto-js": "^3.1.9-1",
"css-hot-loader": "^1.4.4",
"css-loader": "^1.0.1",
"es6-promise": "^4.2.8",
"eslint": "^4.19.1",
"eslint-config-prettier": "^6.5.0",
"eslint-config-vue": "^2.0.2",
"eslint-plugin-html": "^4.0.6",
"eslint-plugin-prettier": "^3.1.1",
"file-loader": "^1.1.11",
"file-saver": "^1.3.8",
"glob": "^7.1.4",
"html-loader": "^0.5.0",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.9.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"pkg": "^4.4.0",
"postcss-loader": "^2.0.6",
"sass-loader": "^7.1.0",
"secure-web-storage": "^1.0.2",
"style-loader": "^0.18.2",
"url-loader": "^1.1.2",
"vue-awesome-swiper": "^3.1.3",
"vue-axios": "^2.1.4",
"vue-i18n": "^8.11.2",
"vue-jest": "^3.0.5",
"vue-loader": "^14.2.2",
"webpack": "^4.39.3",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.3.5",
"webpack-dev-server": "^3.7.2",
"webpack-merge": "^4.2.1"
},
"bin": {
"app": "./server.js"
},
"lint": "eslint --ext .js,.vue src",
"pkg": {
"assets": [
"dist/**/*"
]
}
}
Please tell me if you need more information. I'll add it.
Thank you for read this question.
This is self answer. Well it was silly problem.
There are three problem
preset: '#vue/cli-plugin-unit-jest/presets/no-babel' in jest.config.js make transform option useless
removed
Jest 24 dosen't support babel 6.
it should be
babel-jest": "^23.6.0"
transform's location was wrong
it should be like
transform: {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
}
Now i fixed three problem. and working good.
I leave this answer because I want my shameful behavior to help others.

How to fix regeneratorRuntime error async method with babel 7.5 + runtime + plugin-transform-runtime

I try to use async/await on a js script (class method) in a webpack config but i have got this error :
search.js:33 Uncaught ReferenceError: regeneratorRuntime is not defined
I have maybe an error in the babelrc file but i tried all things found on the web :/
Stack : WSL1 node 10.16.3 npm 6.11.1 in Visual Studio Code.
Previously, i had polyfill config with a similar problem.
I tried to use new Babel recommandations with #babel/plugin-transform-runtime and #babel/runtime but the issue persists.
I tried to remove /node_modules/ directory and lock package files to generate it again with npm i but nothing changes.
I have no problem with an async function declaration (outside a class).
File with generated error
class Search {
constructor() {...}
async run() {
await this.xxxx();
}
xxxx() {...}
}
.babelrc
{
"presets": [
["#babel/preset-env"],
[
"#babel/env",
{
"modules": false,
"useBuiltIns": "usage",
"corejs": 3
}
]
],
"plugins": [
[ "#babel/plugin-transform-runtime", {"regenerator": true, "corejs": 3} ],
[ "#babel/plugin-transform-async-to-generator" ]
]
}
package.json
{
...
"devDependencies": {
"#babel/core": "^7.5.5",
"#babel/plugin-syntax-dynamic-import": "^7.2.0",
"#babel/plugin-transform-async-to-generator": "^7.5.0",
"#babel/plugin-transform-runtime": "^7.6.2",
"#babel/preset-env": "^7.6.3",
"autoprefixer": "^9.6.1",
"babel-loader": "^8.0.6",
"clean-webpack-plugin": "^2.0.2",
"css-loader": "^2.1.1",
"file-loader": "^3.0.1",
"fontmin-webpack": "^2.0.4",
"imagemin-gifsicle": "^6.0.1",
"imagemin-jpegtran": "^6.0.0",
"imagemin-optipng": "^7.0.0",
"imagemin-svgo": "^7.0.0",
"imagemin-webpack": "^5.1.0",
"jquery": "^3.4.1",
"loader": "^2.1.1",
"mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss-cli": "^6.1.2",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"sass-loader": "^7.3.1",
"style": "0.0.3",
"style-loader": "^0.23.1",
"sugarss": "^2.0.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.7",
"webpack-manifest-plugin": "^2.0.4"
},
"dependencies": {
"#babel/runtime": "^7.6.3",
"core-js": "^3.3.2",
"detect-it": "^3.0.5",
"gifsicle": "^4.0.1",
"slick-carousel": "^1.8.1"
},
"browserslist": [
"last 2 versions"
]
}
I found the solution.
In the main js file
import "regenerator-runtime/runtime";
Add regenerator-runtime
npm i regenerator-runtime
Thanks.

How to fix: this.setDynamic is not a function

There is some problem with my babel config, not sure what it is..
Error I am seeing:
ERROR Failed to compile with 1 errors friendly-errors 21:27:50
ERROR in ./.nuxt/client.js friendly-errors 21:27:50
Module build failed (from ./node_modules/#nuxt/webpack/node_modules/babel-loader/lib/index.js): friendly-errors 21:27:50
TypeError: this.setDynamic is not a function
my .babelrc looks like this:
{
"presets": [
[
"vue-app",
{
"useBuiltIns": true
}
],
"flow"
],
"plugins": ["#babel/plugin-proposal-decorators", "#babel/plugin-proposal-class-properties"],
"env": {
"test": {
"plugins": ["babel-jest-assertions", "transform-runtime"]
}
}
}
Package-lock, installed plugins:
"#babel/core": "^7.4.5",
"#babel/preset-env": "^7.4.5",
"#nuxtjs/google-analytics": "^2.2.0",
"acorn": "^6.1.1",
"axios": "^0.18.1",
"babel-jest-assertions": "^0.1.0",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-preset-flow": "^6.23.0",
What needs to be changed for this config to work? Have visited various stackoverflow answers, and have not found a working fix yet.
UPDATED CONFIG AFTER COMMENTS:
"#babel/plugin-transform-runtime": "^7.4.4",
"#babel/polyfill": "^7.4.4",
"#vue/babel-preset-app": "^3.0.0-rc.2",
"autoprefixer": "^7.1.2",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-jest": "^21.0.2",
"babel-loader": "^8.0.0-beta.0",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-imports": "^1.5.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
The answer to this problem is this. Be aware of your babel configuration, ie like mentioned in the comments. Babel 6 will not work correctly with Babel 7 plugins and etc. Thank you for all the provided help in the comments.

CK Editor 5 built from source + Vue JS + Using component locally = duplicated

I have a set of components in my page like this:
BlogEntryPointComponent that contains NewBlogComponent and BlogEditComponent
both NewBlogComponent and BlogEditComponent use the following code:
import BlogEditor from '../../../../js/ckeditor/blogeditor.ts'
export default {
components:{
ckeditor: BlogEditor.ckeditor
},
data(){
return{
editor: BlogEditor.editor,
editorConfig: BlogEditor.config
}
},
...
so now I mount BlogEntryPointComponent but the problem is that this is causing error ckeditor-duplicated-modules: Some CKEditor 5 modules are duplicated
The error page help talks about using two different builds on one page; I guess I am in this case... but those are are two different independent components; how can this be ?
So I tried building the editor from source as per what the doc recommends and I have the same problem..
the editor is the same imported file in both components.
here is the editor:
import EssentialsPlugin from '#ckeditor/ckeditor5-essentials/src/essentials';
import UploadAdapterPlugin from '#ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
import AutoformatPlugin from '#ckeditor/ckeditor5-autoformat/src/autoformat';
import BoldPlugin from '#ckeditor/ckeditor5-basic-styles/src/bold';
import ItalicPlugin from '#ckeditor/ckeditor5-basic-styles/src/italic';
import BlockQuotePlugin from '#ckeditor/ckeditor5-block-quote/src/blockquote';
import HeadingPlugin from '#ckeditor/ckeditor5-heading/src/heading';
import LinkPlugin from '#ckeditor/ckeditor5-link/src/link';
import ListPlugin from '#ckeditor/ckeditor5-list/src/list';
import ParagraphPlugin from '#ckeditor/ckeditor5-paragraph/src/paragraph';
import AlignmentPlugin from '#ckeditor/ckeditor5-alignment/src/alignment';
import EmbedPlugin from '#ckeditor/ckeditor5-media-embed/src/mediaembed';
import MentionPlugin from '#ckeditor/ckeditor5-mention/src/mention';
import HighlightPlugin from '#ckeditor/ckeditor5-highlight/src/highlight'
import ClassicEditorBase from '#ckeditor/ckeditor5-editor- classic/src/classiceditor';
import CKEditor from '#ckeditor/ckeditor5-vue/dist/ckeditor.js'
export default {
ckeditor: CKEditor.component,
editor:ClassicEditorBase,
config:{
plugins: [
EssentialsPlugin,
BoldPlugin,
ItalicPlugin,
LinkPlugin,
ParagraphPlugin,
AlignmentPlugin,
ListPlugin,
HeadingPlugin,
BlockQuotePlugin,
AutoformatPlugin,
UploadAdapterPlugin,
EmbedPlugin,
MentionPlugin,
HighlightPlugin
],
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'alignment',
'link',
'bulletedList',
'numberedList',
'mediaEmbed',
'blockQuote',
'highlight',
'undo',
'redo'
]
}
}
}
package.json
{
"devDependencies": {
"#babel/core": "^7.0.0",
"#babel/preset-env": "^7.4.5",
"#babel/preset-typescript": "^7.1.0",
"#babel/register": "^7.0.0",
"#ckeditor/ckeditor5-adapter-ckfinder": "^11.0.1",
"#ckeditor/ckeditor5-alignment": "^11.1.0",
"#ckeditor/ckeditor5-autoformat": "^11.0.1",
"#ckeditor/ckeditor5-basic-styles": "^11.1.0",
"#ckeditor/ckeditor5-block-quote": "^11.0.1",
"#ckeditor/ckeditor5-dev-utils": "^12.0.1",
"#ckeditor/ckeditor5-dev-webpack-plugin": "^8.0.1",
"#ckeditor/ckeditor5-easy-image": "^11.0.1",
"#ckeditor/ckeditor5-editor-classic": "^12.1.0",
"#ckeditor/ckeditor5-essentials": "^11.0.1",
"#ckeditor/ckeditor5-heading": "^11.0.1",
"#ckeditor/ckeditor5-image": "^13.0.1",
"#ckeditor/ckeditor5-link": "^11.0.1",
"#ckeditor/ckeditor5-list": "^12.0.1",
"#ckeditor/ckeditor5-paragraph": "^11.0.1",
"#ckeditor/ckeditor5-theme-lark": "^13.0.1",
"#ckeditor/ckeditor5-undo": "^11.0.1",
"#types/jquery": "^3.3.22",
"babel-loader": "^8.0.4",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.5.4",
"css-loader": "^2.1.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^2.0.0",
"html-webpack-plugin": "^3.2.0",
"imports-loader": "^0.8.0",
"jquery": "^3.3.1",
"less-loader": "^4.1.0",
"mini-css-extract-plugin": "^0.7.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"sass-loader": "^7.1.0",
"select2": "^4.0.6-rc.1",
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^1.3.0",
"to-string-loader": "^1.1.5",
"toastr": "^2.1.4",
"ts-loader": "^5.2.2",
"tslint": "^5.11.0",
"typescript": "^3.1.3",
"url-loader": "^1.1.2",
"vue-cool-select": "^1.6.2",
"vue-loader": "^15.6.1",
"vue-select": "2.4.0",
"vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.5.22",
"webpack": "^4.32.2",
"webpack-cli": "^3.1.2",
"webpack-manifest-plugin": "^2.0.4",
"webpack-notifier": "^1.7.0",
"write-file-webpack-plugin": "^4.4.1"
},
"dependencies": {
"#ckeditor/ckeditor5-build-classic": "^12.1.0",
"#ckeditor/ckeditor5-build-decoupled-document": "^12.1.0",
"#ckeditor/ckeditor5-highlight": "^11.0.1",
"#ckeditor/ckeditor5-media-embed": "^11.1.0",
"#ckeditor/ckeditor5-mention": "^10.0.0",
"#ckeditor/ckeditor5-vue": "^1.0.0-beta.2",
"axios": "^0.19.0",
"moment": "^2.24.0",
"postcss-loader": "^3.0.0",
"pretty-checkbox-vue": "^1.1.9",
"raw-loader": "^0.5.1",
"svg-url-loader": "^2.3.2",
"vue": "^2.5.22",
"vue-date-pick": "^1.1.0",
"vue-router": "^3.0.2",
"vuelayers": "^0.11.4"
}
What I did is I updated all the packages related to ckeditor5 and added #ckeditor/ckeditor5-ui#latest
When I updated all the packages related to ck5editor I encounred this new multiple errors
plugincollection-plugin-name-conflict through duplicate.....
https://github.com/ckeditor/ckeditor5/issues/1505
so I deleted the node_modules and package.lock or yarn.lock and npm install again
Most probably the cause of the errors is if you have newer version of some plugins and also have older version, it will return an error since it seems you are using both the new and old version or you can't use newer version of plugins with older version of core plugins