File tree 8 files changed +33
-58
lines changed 8 files changed +33
-58
lines changed Original file line number Diff line number Diff line change
1
+ import { Config , ConfigFn } from '../types/config'
2
+ import { Callback } from '../types/utils'
1
3
import { prettyDOM } from './pretty-dom'
2
- import { Callback } from './types'
3
-
4
- export interface Config {
5
- testIdAttribute : string
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- asyncWrapper ( cb : ( ...args : any [ ] ) => any ) : Promise < any >
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- eventWrapper ( cb : ( ...args : any [ ] ) => any ) : void
10
- asyncUtilTimeout : number
11
- computedStyleSupportsPseudoElements : boolean
12
- defaultHidden : boolean
13
- showOriginalStackTrace : boolean
14
- throwSuggestions : boolean
15
- getElementError : ( message : string | null , container : Element ) => Error
16
- }
17
-
18
- export interface ConfigFn {
19
- ( existingConfig : Config ) : Partial < Config >
20
- }
21
4
22
5
interface InternalConfig {
23
6
_disableExpensiveErrorDiagnostics : boolean
Original file line number Diff line number Diff line change 1
- import { ARIARole } from 'aria-query'
2
- import { Nullish } from './types'
3
-
4
- export type ByRoleMatcher = ARIARole | MatcherFunction | { }
5
-
6
- export type Matcher = MatcherFunction | RegExp | string
7
-
8
- export type MatcherFunction = (
9
- content : string ,
10
- element : Nullish < Element > ,
11
- ) => boolean
12
-
13
- export type NormalizerFn = ( text : string ) => string
14
-
15
- export interface DefaultNormalizerOptions {
16
- trim ?: boolean
17
- collapseWhitespace ?: boolean
18
- }
19
-
20
- export interface MatcherOptions {
21
- exact ?: boolean
22
- /** Use normalizer with getDefaultNormalizer instead */
23
- trim ?: boolean
24
- /** Use normalizer with getDefaultNormalizer instead */
25
- collapseWhitespace ?: boolean
26
- normalizer ?: NormalizerFn
27
- /** suppress suggestions for a specific query */
28
- suggest ?: boolean
29
- }
30
-
31
- export type NormalizerOptions = DefaultNormalizerOptions & {
32
- normalizer ?: NormalizerFn
33
- }
1
+ import {
2
+ Matcher ,
3
+ NormalizerFn ,
4
+ NormalizerOptions ,
5
+ DefaultNormalizerOptions ,
6
+ } from '../types'
7
+ import { Nullish } from '../types/utils'
34
8
35
9
function assertNotNullOrUndefined < T > (
36
10
matcher : T ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ const baseConfig = require('kcd-scripts/jest')
3
3
4
4
module . exports = {
5
5
...baseConfig ,
6
+ moduleFileExtensions : [ ...baseConfig . moduleFileExtensions , 'd.ts' ] ,
7
+ moduleDirectories : [ ...baseConfig . moduleDirectories , 'types' ] ,
6
8
rootDir : path . join ( __dirname , '..' ) ,
7
9
displayName : 'dom' ,
8
10
coveragePathIgnorePatterns : [
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ const baseConfig = require('kcd-scripts/jest')
3
3
4
4
module . exports = {
5
5
...baseConfig ,
6
+ moduleFileExtensions : [ ...baseConfig . moduleFileExtensions , 'd.ts' ] ,
7
+ moduleDirectories : [ ...baseConfig . moduleDirectories , 'types' ] ,
6
8
rootDir : path . join ( __dirname , '..' ) ,
7
9
displayName : 'node' ,
8
10
testEnvironment : 'jest-environment-node' ,
Original file line number Diff line number Diff line change 1
1
export interface Config {
2
2
testIdAttribute : string
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
4
asyncWrapper ( cb : ( ...args : any [ ] ) => any ) : Promise < any >
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
6
eventWrapper ( cb : ( ...args : any [ ] ) => any ) : void
5
7
asyncUtilTimeout : number
6
8
computedStyleSupportsPseudoElements : boolean
7
9
defaultHidden : boolean
8
10
showOriginalStackTrace : boolean
9
11
throwSuggestions : boolean
10
- getElementError : ( message : string , container : HTMLElement ) => Error
12
+ getElementError : ( message : string | null , container : Element ) => Error
11
13
}
12
14
13
15
export interface ConfigFn {
Original file line number Diff line number Diff line change 1
1
import { ARIARole } from 'aria-query'
2
+ import { Nullish } from './utils'
2
3
3
- export type MatcherFunction = ( content : string , element : HTMLElement ) => boolean
4
- export type Matcher = MatcherFunction | { }
4
+ export type MatcherFunction = (
5
+ content : string ,
6
+ element : Nullish < Element > ,
7
+ ) => boolean
8
+ export type Matcher = MatcherFunction | RegExp | string
5
9
6
10
// Get autocomplete for ARIARole union types, while still supporting another string
7
11
// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-505826972
8
12
export type ByRoleMatcher = ARIARole | MatcherFunction | { }
9
13
10
14
export type NormalizerFn = ( text : string ) => string
11
15
16
+ export type NormalizerOptions = DefaultNormalizerOptions & {
17
+ normalizer ?: NormalizerFn
18
+ }
19
+
12
20
export interface MatcherOptions {
13
21
exact ?: boolean
14
22
/** Use normalizer with getDefaultNormalizer instead */
Original file line number Diff line number Diff line change
1
+ export type Nullish < T > = T | null | undefined
2
+
3
+ export type Callback < T > = ( ) => T
4
+
5
+ export function isNotNull < T > ( arg : T ) : arg is NonNullable < T > {
6
+ return arg !== null
7
+ }
You can’t perform that action at this time.
0 commit comments