Skip to content

Commit dafbb16

Browse files
author
Ben Monro
committed
feat: support for configure
1 parent c3a08f7 commit dafbb16

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

nightwatch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"src_folders": [
33
"tests/nightwatch"
44
],
5+
"globals_path": "tests/globals",
56
"webdriver": {
67
"start_process": true,
78
"server_path": "node_modules/.bin/chromedriver",

src/index.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,23 @@ const DOM_TESTING_LIBRARY_UMD_PATH = path.join(
1212
const DOM_TESTING_LIBRARY_UMD = fs.readFileSync(DOM_TESTING_LIBRARY_UMD_PATH).toString()
1313
const SIMMERJS = fs.readFileSync(require.resolve('simmerjs/dist/simmer.js')).toString();
1414

15+
let _config = null;
16+
1517
function injectNWTL(browser) {
16-
browser
17-
.execute(DOM_TESTING_LIBRARY_UMD)
18-
browser.execute(SIMMERJS)
18+
browser.execute(DOM_TESTING_LIBRARY_UMD);
19+
20+
browser.execute(SIMMERJS);
21+
22+
if (_config) {
23+
// eslint-disable-next-line no-shadow
24+
browser.execute(function (_config) {
25+
window.TestingLibraryDom.configure(_config);
26+
}, [_config])
27+
}
1928

2029
}
2130

31+
2232
module.exports.getQueriesFrom = (browser) => {
2333
const queries = {};
2434
Object.keys(baseQueries).forEach(queryName => {
@@ -82,4 +92,8 @@ module.exports.getQueriesFrom = (browser) => {
8292
});
8393

8494
return queries;
95+
}
96+
97+
module.exports.configure = (config) => {
98+
_config = config;
8599
}

tests/nightwatch/index.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ const { getQueriesFrom } = require('../../src');
22

33
module.exports = {
44

5-
beforeEach(browser) {
6-
7-
browser
8-
.url('http://localhost:13370')
9-
},
105

116
async 'Button click works'(browser) {
127
const { getByText } = getQueriesFrom(browser);

0 commit comments

Comments
 (0)