Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide external values when exporting to NightWatchJS flat style export. #4

Open
DavyCool84 opened this issue Feb 28, 2019 · 1 comment

Comments

@DavyCool84
Copy link

In the NightWatchExport when a variable is used, this is constructed as: const varFooBar = bar;
It receives the default value that was set when the variable was declared in snaptest. I don't have to point out that defeats the purpose of being able to work with environments in snaptest, but no longer when exporting them to NightWatchJS.

This could be fixed in the looking for a value in the brower.globals.test_setting with a fallback to the default value like is done for the "baseUrl" variable. That way we could pass in parameters and run the same test against different environments.

Flat.js changes:

function defineTestVariables(test) {

var variableDefs = "";

test.variables.forEach((variable) => {
if (variable.name !== "baseUrl") {
// Allow the setting of the variable value through the "globals.test_settings"
variableDefs += const ${variable.name} = browser.globals.test_settings[${variablename}] || \${variable.defaultValue}`;`;
}
});

return variableDefs;
}

DavyCool84 pushed a commit to DavyCool84/snaptest-cli that referenced this issue Feb 28, 2019
Provide external values when exporting to NightWatchJS flat style export. snaptest-io#4
@ozymandias547
Copy link
Collaborator

You're absolutely right, the variables need to work similar to how the baseUrl works currently, by pulling in the variable names from the global config. We're making some large updates to this generator very soon and variables will become much more standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants