diff --git a/.eslintrc b/.eslintrc index c416e76..5b4724c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,4 @@ { - "parser": "@babel/eslint-parser", "extends": "eslint:recommended", "parserOptions": { "ecmaVersion": 6, @@ -36,6 +35,7 @@ "no-spaced-func": 2, "no-undef-init": 2, "no-unused-expressions": 2, + "no-var": 2, "no-with": 2, "camelcase": 2, "comma-spacing": 2, diff --git a/.gitignore b/.gitignore index 1d1bd01..0c492ea 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,5 @@ Temporary Items node_modules/* .idea/* -lib/* test/data/lib/* package-lock.json diff --git a/src/index.js b/lib/index.js similarity index 87% rename from src/index.js rename to lib/index.js index 4621ce6..f8cb227 100644 --- a/src/index.js +++ b/lib/index.js @@ -1,9 +1,9 @@ -import { Selector } from 'testcafe'; +const { Selector } = require('testcafe'); -export default Selector(complexSelector => { +module.exports = Selector(complexSelector => { function validateSelector (selector) { if (selector !== void 0 && typeof selector !== 'string') - throw new Error('If the selector parameter is passed it should be a string, but it was ' + eval('typeof selector')); // eslint-disable-line no-eval + throw new Error('If the selector parameter is passed it should be a string, but it was ' + typeof selector); } function validateVueVersion (rootInstance) { @@ -14,19 +14,14 @@ export default Selector(complexSelector => { throw new Error('testcafe-vue-selectors supports Vue version 2.x and newer'); } - /*eslint-disable no-unused-vars, no-eval*/ function findVueConstructor (rootInstance) { - // NOTE: Testcafe does not support a ClientFunction containing polyfilled functions. See list in - // https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-runtime/src/definitions.js. - // This is why, we use this hack. - let Vue = eval('Object.getPrototypeOf(rootInstance)').constructor; + let Vue = Object.getPrototypeOf(rootInstance).constructor; while (Vue.super) Vue = Vue.super; return Vue; } - /*eslint-enable no-unused-vars, no-eval*/ function findFirstRootInstance () { let instance = null; @@ -95,9 +90,9 @@ export default Selector(complexSelector => { } walkVueComponentNodes(root, 0, (node, tagIndex) => { - if (isRef(tags[tagIndex])) { + if (isRef(tags[tagIndex])) { const ref = getRef(tags[tagIndex]); - + return ref === getRefOfNode(node); } return tags[tagIndex] === getComponentTag(node); @@ -157,7 +152,7 @@ export default Selector(complexSelector => { } function getComponentReference (instance) { - return instance.$vnode && instance.$vnode.data && instance.$vnode.data.ref; + return instance.$vnode && instance.$vnode.data && instance.$vnode.data.ref; } const nodeVue = node.__vue__; diff --git a/package.json b/package.json index 2a4d166..a3ab166 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "testcafe-vue-selectors", - "version": "3.1.0", + "version": "3.1.1", "description": "VueJS selectors for TestCafe", "repository": "https://github.com/DevExpress/testcafe-vue-selectors", "author": { @@ -13,18 +13,14 @@ ], "license": "MIT", "scripts": { - "lint": "eslint src/index.js", + "lint": "eslint lib/index.js", "test-server": "webpack-dev-server", "testcafe": "testcafe all test/*.js --app \"npm run test-server\" --app-init-delay 10000", - "test": "npm run lint && npm run build && npm run testcafe", - "build": "babel src --out-dir lib", + "test": "npm run lint && npm run testcafe", "publish-please": "publish-please", "prepublish": "publish-please guard" }, "devDependencies": { - "@babel/cli": "^7.13.0", - "@babel/core": "^7.13.8", - "@babel/eslint-parser": "^7.13.8", "babel-loader": "^8.2.2", "css-loader": "^5.1.1", "eslint": "^7.21.0",