-
Notifications
You must be signed in to change notification settings - Fork 29
feat: export configure function with data-testid override #39
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ import * as path from 'path' | |||||
import {ElementHandle, EvaluateFn, JSHandle, Page} from 'puppeteer' | ||||||
import waitForExpect from 'wait-for-expect' | ||||||
|
||||||
import {IQueryUtils, IScopedQueryUtils} from './typedefs' | ||||||
import {IQueryUtils, IScopedQueryUtils, Config} from './typedefs' | ||||||
|
||||||
const domLibraryAsString = readFileSync( | ||||||
path.join(__dirname, '../dom-testing-library.js'), | ||||||
|
@@ -17,7 +17,7 @@ function mapArgument(argument: any, index: number): any { | |||||
: argument | ||||||
} | ||||||
|
||||||
const delegateFnBodyToExecuteInPage = ` | ||||||
let delegateFnBodyToExecuteInPage = ` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's save the original as |
||||||
${domLibraryAsString}; | ||||||
|
||||||
const mappedArgs = args.map(${mapArgument.toString()}); | ||||||
|
@@ -130,6 +130,21 @@ export function wait( | |||||
return waitForExpect(callback, timeout, interval) | ||||||
} | ||||||
|
||||||
export function configure(newConfig: Partial<Config>) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const { testIdAttribute } = newConfig; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if ( | ||||||
testIdAttribute && | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
this one is redundant with the other checks :) |
||||||
typeof testIdAttribute === 'string' && | ||||||
testIdAttribute !== '' | ||||||
) { | ||||||
delegateFnBodyToExecuteInPage = delegateFnBodyToExecuteInPage.replace( | ||||||
`testIdAttribute: 'data-testid'`, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this pattern only ever occur once or do we need a global replace? |
||||||
`testIdAttribute: '${newConfig.testIdAttribute}'` | ||||||
) | ||||||
} | ||||||
} | ||||||
|
||||||
export function getQueriesForElement<T>( | ||||||
object: T, | ||||||
contextFn?: ContextFn, | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -58,3 +58,7 @@ export interface IQueryUtils extends IQueryMethods { | |||||
getQueriesForElement(): IQueryUtils & IScopedQueryUtils | ||||||
getNodeText(el: Element): Promise<string> | ||||||
} | ||||||
|
||||||
export interface Config { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
testIdAttribute: string; | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.