|
1 |
| -import {setupBrowser, configure} from '../src'; |
| 1 | +import {setupBrowser, configure} from '../src' |
2 | 2 |
|
3 | 3 | describe('configure', () => {
|
4 |
| - beforeEach(() => { |
5 |
| - configure({testIdAttribute: 'data-automation-id'}) |
6 |
| - }) |
7 | 4 | afterEach(() => {
|
8 | 5 | configure({})
|
9 | 6 | })
|
10 | 7 |
|
11 |
| - it('supports alternative testIdAttribute', async () => { |
| 8 | + it('supports setting testIdAttribute', async () => { |
| 9 | + configure({testIdAttribute: 'data-automation-id'}) |
| 10 | + |
12 | 11 | const {getByTestId} = setupBrowser(browser)
|
13 | 12 |
|
14 | 13 | expect(await getByTestId('image-with-random-alt-tag')).toBeDefined()
|
15 | 14 | })
|
16 | 15 |
|
| 16 | + it('supports setting asyncUtilTimeout', async () => { |
| 17 | + configure({asyncUtilTimeout: 0}) |
| 18 | + |
| 19 | + const {findByText} = setupBrowser(browser) |
| 20 | + |
| 21 | + await expect(() => |
| 22 | + findByText('Unique Delayed Button Text'), |
| 23 | + ).rejects.toThrowError() |
| 24 | + }) |
| 25 | + |
| 26 | + it('supports setting computedStyleSupportsPseudoElements', async () => { |
| 27 | + configure({computedStyleSupportsPseudoElements: true}) |
| 28 | + |
| 29 | + const {getByRole} = setupBrowser(browser) |
| 30 | + |
| 31 | + expect( |
| 32 | + await getByRole('button', {name: 'Named by pseudo element'}), |
| 33 | + ).toBeDefined() |
| 34 | + }) |
| 35 | + |
| 36 | + it('supports setting defaultHidden', async () => { |
| 37 | + configure({defaultHidden: true}) |
| 38 | + |
| 39 | + const {getByRole} = setupBrowser(browser) |
| 40 | + |
| 41 | + expect(await getByRole('button', {name: 'Hidden button'})).toBeDefined() |
| 42 | + }) |
| 43 | + |
| 44 | + it('supports setting throwSuggestions', async () => { |
| 45 | + configure({throwSuggestions: true}) |
| 46 | + |
| 47 | + const {getByTestId} = setupBrowser(browser) |
| 48 | + |
| 49 | + await expect(() => |
| 50 | + getByTestId('button-that-should-not-use-testid'), |
| 51 | + ).rejects.toThrowError( |
| 52 | + 'TestingLibraryElementError: A better query is available', |
| 53 | + ) |
| 54 | + }) |
| 55 | + |
17 | 56 | it('works after navigation', async () => {
|
18 |
| - const {getByText, findByTestId} = setupBrowser(browser) |
| 57 | + const {getByText, findByAltText} = setupBrowser(browser) |
19 | 58 |
|
20 | 59 | const goToPageTwoLink = await getByText('Go to Page 2')
|
21 | 60 | await goToPageTwoLink.click()
|
22 | 61 |
|
23 |
| - expect(await findByTestId('page2-thing')).toBeDefined() |
| 62 | + expect(await findByAltText('page two thing')).toBeDefined() |
24 | 63 | })
|
25 | 64 | })
|
0 commit comments