Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

check return type jest

expect(result instanceof Date).toBe(true)

// Another example to match primitive types:
expect(typeof target).toBe("boolean")
expect(typeof target).toBe("number")
expect(typeof target).toBe("string")
expect(typeof target).toBe('function')

expect(Array.isArray(target)).toBe(true)
expect(target && typeof target === 'object').toBe(true)

expect(target === null).toBe('null')
expect(target === undefined).toBe('undefined')

expect(!!target && typeof target.then === 'function').toBe(true)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #return #type #jest
ADD COMMENT
Topic
Name
8+9 =