Repository URL to install this package:
|
Version:
4.0.0-beta.4 ▾
|
export interface SetupOptions {
shouldUseJsdom?: boolean
shouldUseExotic?: boolean
shouldUseEnzyme?: boolean
shouldUseReactTestingLibrary?: boolean
/* only ever true :P */
shouldUseTypeScript?: true
shouldUseSonarQube?: boolean
shouldUseStoryBook?: boolean
shouldExtendExpectWithDocumentObjectModel?: boolean
shouldUseRequestAnimationFrame?: boolean
}
// or could do `no-react`
const shouldUseReact = process.argv.slice(2).includes('--react')
export const DEFAULT_OPTIONS: SetupOptions = Object.freeze({
shouldUseJsdom: shouldUseReact,
shouldUseEnzyme: shouldUseReact,
shouldUseReactTestingLibrary: shouldUseReact,
shouldUseExotic: true,
shouldUseSonarQube: false,
shouldUseStoryBook: false,
shouldExtendExpectWithDocumentObjectModel: false,
shouldUseRequestAnimationFrame: true,
})
export function setupTestFrameworkScript(options: SetupOptions) {
const mergedOptions = { ...DEFAULT_OPTIONS, ...options }
if (mergedOptions.shouldUseJsdom === true) {
require('./jsdom')
}
if (mergedOptions.shouldUseRequestAnimationFrame === true) {
// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet.
// We don't polyfill it in the browser--this is user's responsibility.
require('raf').polyfill(global)
}
if (mergedOptions.shouldUseEnzyme === true) {
require('./enzyme')
}
if (mergedOptions.shouldExtendExpectWithDocumentObjectModel === true) {
require('./extendDocumentObjectModel')
}
if (mergedOptions.shouldUseReactTestingLibrary === true) {
require('./reactTestingLibrary')
}
if (mergedOptions.shouldUseExotic === true) {
require('./extendExotic')
}
if (mergedOptions.shouldUseStoryBook === true) {
console.warn('@todo shouldUseStoryBook was used, not implemented yet')
}
if (mergedOptions.shouldUseSonarQube === true) {
console.warn('shouldUseSonarQube was used, not implemented yet')
}
}