Skip to content

Commit f9fd69f

Browse files
author
Ben Monro
committed
fix: removed globals from src, inject NWTL on every query
1 parent 2d9858e commit f9fd69f

File tree

5 files changed

+26
-89
lines changed

5 files changed

+26
-89
lines changed

nightwatch.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"src_folders": [
33
"tests/nightwatch"
44
],
5-
"globals_path": "src/globals",
65
"webdriver": {
76
"start_process": true,
87
"server_path": "node_modules/.bin/chromedriver",

src/globals/index.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1+
2+
const path = require('path');
3+
const fs = require('fs');
14
const { queries: baseQueries } = require('@testing-library/dom');
5+
// import { queries } from '@testing-library/dom'
6+
7+
const DOM_TESTING_LIBRARY_UMD_PATH = path.join(
8+
require.resolve('@testing-library/dom'),
9+
'../../',
10+
'dist/@testing-library/dom.umd.js',
11+
)
12+
const DOM_TESTING_LIBRARY_UMD = fs.readFileSync(DOM_TESTING_LIBRARY_UMD_PATH).toString()
13+
const SIMMERJS = fs.readFileSync(require.resolve('simmerjs/dist/simmer.js')).toString();
14+
15+
function injectNWTL(browser) {
16+
browser
17+
.execute(DOM_TESTING_LIBRARY_UMD)
18+
browser.execute(SIMMERJS)
19+
20+
}
221

322
module.exports.getQueriesFrom = (browser) => {
423
const queries = {};
@@ -10,6 +29,8 @@ module.exports.getQueriesFrom = (browser) => {
1029
}
1130
return arg;
1231
})
32+
33+
injectNWTL(browser)
1334
// eslint-disable-next-line no-shadow
1435
browser.execute(function (queryName, ...args) {
1536
try {

tests/nightwatch/index.test.js

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

33
module.exports = {
44

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

611
async 'Button click works'(browser) {
712
const { getByText } = getQueriesFrom(browser);

typings/index.d.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)