CodeceptJS
CodeceptJS copied to clipboard
Variables are undefined in shell mode
What are you trying to achieve?
Use current value of variables in interactive shell launched during active test scenario using pause() command, ex:
I.fillField('input#firstName', current.FirstName)
What do you get instead?
ERROR current is not defined
Provide console output if related. Use
--verbosemode for more details.
I.say(localVar)
ERROR localVar is not defined
I.say(globalVar)
ERROR globalVar is not defined
I.say(current.search)
ERROR current is not defined
I.
Provide test source code if related
// bug_test.js
/// <reference path="./steps.d.ts" />
let globalVar = 'there';
Feature('Shell mode');
const search = new DataTable(['search']);
search.add(['codeceptjs'])
Data(search)
.Scenario('variables should be defined in shell', (I, current) => {
I.amOnPage('/');
let localVar = 'Hi';
// all work here...
I.fillField('#search_form_input_homepage', `${localVar} ${globalVar} ${current.search}!`)
// none defined in shell...
I.say(`Try: I.say(\`\${localVar}\`)`);
I.say(`Try: I.say(\`\${globalVar}\`)`);
I.say(`Try: I.say(\`\${current.search}\`)`); // ... including special data driven 'current' variable
pause() // <--- see video for repro steps once shell opens
});
Details
- CodeceptJS version: ^1.3.2
- NodeJS Version: v10.6.0
- Operating System: Edition: Windows 10 Home Version: 1803 OS build: 17134.165
- WebDriverIO version: how to find?
- Configuration file:
paste suite config here
// codecept.json
{
"tests": "./*_test.js",
"timeout": 10000,
"output": "./output",
"helpers": {
"WebDriverIO": {
"url": "https://start.duckduckgo.com",
"browser": "chrome",
"desiredCapabilities": {
"chromeOptions": {
"args": [ "--start-maximized", "--disable-infobars"]
}
}
}
},
"include": {
"I": "./steps_file.js"
},
"bootstrap": false,
"mocha": {},
"name": "codeceptjs-bug-repro"
}
// package.json
{
"name": "codeceptjs-bug-repro",
"version": "1.0.0",
"description": "All variables undefined after entering interactive shell mode using pause() command during active test scenario",
"main": "index.js",
"scripts": {
"postinstall": "selenium-standalone install",
"start": "selenium-standalone start",
"test": "codeceptjs run --steps"
},
"author": "Eric Smith",
"license": "MIT",
"devDependencies": {
"codeceptjs": "^1.3.2",
"selenium-standalone": "^6.15.1"
}
}