diff --git a/package.json b/package.json index 205174d..31be930 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,9 @@ "test": "npm-run-all --parallel test:unit test:testcafe", "semantic-release": "semantic-release" }, - "files": [ "dist" ], + "files": [ + "dist" + ], "keywords": [], "author": "", "license": "ISC", diff --git a/src/index.js b/src/index.js index 01122d9..b72fba3 100644 --- a/src/index.js +++ b/src/index.js @@ -2,8 +2,8 @@ /* eslint-disable no-new-func */ import fs from 'fs' import path from 'path' -import {ClientFunction, Selector} from 'testcafe' -import {queries} from 'dom-testing-library' +import { ClientFunction, Selector } from 'testcafe' +import { queries } from 'dom-testing-library' const LIBRARY_UMD_PATH = path.join( './node_modules', @@ -20,11 +20,11 @@ export const addTestcafeTestingLibrary = async t => { window.TestCafeTestingLibrary = {} }, { - dependencies: {script: LIBRARY_UMD_CONTENT}, + dependencies: { script: LIBRARY_UMD_CONTENT }, }, ) - await inject.with({boundTestRun: t})() + await inject.with({ boundTestRun: t })() } Object.keys(queries).forEach(queryName => { @@ -60,3 +60,12 @@ export const within = async sel => { return container } + + +export const configure = async options => { + await ClientFunction(new Function( + ` + window.DomTestingLibrary.configure(${JSON.stringify(options)}); + ` + )) +} \ No newline at end of file diff --git a/test-app/index.html b/test-app/index.html index 42ac5e4..49024d5 100644 --- a/test-app/index.html +++ b/test-app/index.html @@ -1,74 +1,72 @@ - - - - - testcafe-testing-library - - - -
- No auto-reload after changing this static HTML markup: click - Run All Tests. -
-
-

getByPlaceholderText

- -
-
-

getByText

+ + + + + + testcafe-testing-library + + + + +
+ No auto-reload after changing this static HTML markup: click + Run All Tests. +
+
+

getByPlaceholderText

+ +
+
+

getByText

+ +
+

getByText within

-
-

getByText within

- -
-
-
-

getByLabelText

- - -
-
-

getByAltText

- Image Alt Text -
-
-

getByTestId

- -
-
-

getAllByText

- - -
- - - - + +
+
+

getByLabelText

+ + +
+
+

getByAltText

+ Image Alt Text +
+
+

getByTestId

+ +
+
+

configure

+ +
+
+

getAllByText

+ + +
+ + + + + \ No newline at end of file diff --git a/tests/testcafe/configure.js b/tests/testcafe/configure.js new file mode 100644 index 0000000..dfc4f95 --- /dev/null +++ b/tests/testcafe/configure.js @@ -0,0 +1,16 @@ +/* eslint-disable import/named */ +import { configure, getByTestId, addTestcafeTestingLibrary } from '../../src' + + + +// eslint-disable-next-line babel/no-unused-expressions +fixture`configure`.beforeEach(addTestcafeTestingLibrary) + .page`http://localhost:13370` + + +test('configure', async t => { + await configure({ testIdAttribute: 'data-automation-id' }); + + await t + .click(getByTestId('image-with-random-alt-tag')) +}) \ No newline at end of file diff --git a/tests/unit/__snapshots__/selectors.test.js.snap b/tests/unit/__snapshots__/selectors.test.js.snap index b57cc1f..241ec06 100644 --- a/tests/unit/__snapshots__/selectors.test.js.snap +++ b/tests/unit/__snapshots__/selectors.test.js.snap @@ -4,6 +4,7 @@ exports[`exports expected selectors 1`] = ` Array [ "addTestcafeTestingLibrary", "within", + "configure", "queryAllByLabelText", "getAllByLabelText", "queryByLabelText",