-
Notifications
You must be signed in to change notification settings - Fork 728
Add testcafe-testing-library #88
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1bbca3b
Create intro.md
benmonro b3a67ec
doc: added testcafe-testing-library docs
dd17808
doc: cleaned up some little details
142db0b
Merge branch 'master' into master
benmonro 203fd23
added note for container
4dfc6c1
Merge branch 'master' of github.com:benmonro/testing-library-docs
d2fcef1
Merge branch 'master' into master
benmonro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
id: intro | ||
title: Testcafe Testing Library | ||
--- | ||
|
||
[`testcafe-testing-library`][gh] allows the use of dom-testing queries within | ||
[Testcafe](https://devexpress.github.io/testcafe/) cross-browser end-to-end web | ||
testing. | ||
|
||
``` | ||
npm install --save-dev testcafe testcafe-testing-library | ||
``` | ||
|
||
- [testcafe-testing-library on GitHub][gh] | ||
|
||
## Usage | ||
|
||
`testcafe-testing-library` provides custom Selectors allowing you to query the | ||
dom. | ||
|
||
Add `testcafe-testing-library` to your test fixture's `beforeEach` hook: | ||
|
||
```javascript | ||
import { | ||
getByText, //or any other queries you want | ||
addTestcafeTestingLibrary, | ||
} from 'testcafe-testing-library' | ||
|
||
fixture`selectors`.beforeEach(addTestcafeTestingLibrary) | ||
.page`http://localhost:13370` | ||
``` | ||
|
||
You can now import & use `getBy`, `getAllBy`, `queryBy` and `queryAllBy` | ||
selectors in your tests. | ||
[See `dom-testing-library` API for reference](dom-testing-library/api-queries.md) | ||
|
||
## Examples | ||
|
||
To show some simple examples (from | ||
[https://github.com/benmonro/testcafe-testing-library/blob/master/tests/testcafe/selectors.js](https://github.com/benmonro/testcafe-testing-library/blob/master/tests/testcafe/selectors.js)): | ||
|
||
```javascript | ||
test('getByPlaceHolderText', async t => { | ||
await t.typeText( | ||
getByPlaceholderText('Placeholder Text'), | ||
'Hello Placeholder' | ||
) | ||
}) | ||
test('getByText', async t => { | ||
await t.click(getByText('getByText')) | ||
}) | ||
|
||
test('getByLabelText', async t => { | ||
await t.typeText( | ||
getByLabelText('Label For Input Labelled By Id'), | ||
'Hello Input Labelled By Id' | ||
) | ||
}) | ||
``` | ||
|
||
[gh]: https://github.com/benmonro/testcafe-testing-library |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.