Today I start working with testing through the Selenium WebDriver, but I ran into this problem (error):
ReferenceError: after is not defined
I managed to find out that after
is a global variable from the Jasmine
and Mocha
libraries. But I could not do anything with it anyway.
My unit testing is carried out with Jest
and I dont want to change it to Mocha
.
The test (basic) looks like this (google_search_test.js):
const {Browser, By, Key, until} = require('selenium-webdriver');
const {ignore, suite} = require('selenium-webdriver/testing');
suite(function(env) {
describe('Google Search', function() {
let driver;
beforeEach(async function() {
driver = await env.builder()
.forBrowser('chrome')
.build();
});
it('demo', async function() {
await driver.get('https://www.google.com/ncr');
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
});
ignore(env.browsers(Browser.CHROME)).it('demo 2', async function() {
await driver.get('https://www.google.com/ncr');
await driver.wait(until.urlIs('https://www.google.com/'), 1500);
});
after(() => driver.quit());
});
});
Package.json looks like this:
{
"name": "crmvuesimple",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"unit": "jest"
},
"dependencies": {
"axios": "^0.19.0",
"core-js": "^3.3.2",
"i": "^0.3.6",
"idle-vue": "^2.0.5",
"jwt-decode": "^2.2.0",
"moment": "^2.24.0",
"socket.io-client": "^2.3.0",
"vue": "^2.6.10",
"vue-lodash": "^2.0.2",
"vue-router": "^3.1.3",
"vue-select": "^3.2.0",
"vue-tel-input": "^4.0.0",
"vuelidate": "^0.7.4",
"vuex": "^3.0.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.0.0",
"@vue/cli-service": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.30",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.9.0",
"chromedriver": "^79.0.0",
"geckodriver": "^1.19.1",
"jest": "^24.9.0",
"jest-environment-selenium": "^2.1.2",
"selenium-webdriver": "^4.0.0-alpha.5",
"vue-jest": "^3.0.5",
"vue-template-compiler": "^2.6.10"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"vue"
],
"transform": {
"^.+\\.(js)$": "babel-jest",
".*\\.(vue)$": "vue-jest"
},
"modulePaths": [
"<rootDir>"
]
}
}
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire