Receiving function prop as undefined
rafaellages-hotmart opened this issue · 0 comments
rafaellages-hotmart commented
Hi guys Im having a weird problem where my component receive a function parameter as undefined if:
It is not declared in the same scope
OR
I don't declare and pass other variables on the same scope
describe('myTest', () => {
let myComponent
let myMock
beforeEach(() => {
myMock = jest.fn()
myComponent = shallow(
<MyComponent action={myMock} />
)
})
})
FAIL this.props.action is undefined
describe('myTest', () => {
let myComponent
beforeEach(() => {
let myMock = jest.fn() // declared on the same block
myComponent = shallow(
<MyComponent action={myMock} />
)
})
})
WORKS this.props.action is my mock
describe('myTest', () => {
let myComponent
let myMock
beforeEach(() => {
myMock = jest.fn()
let anything = 'anything' // anything else declared and passed in the same block
myComponent = shallow(
<MyComponent action={myMock} anything={anything}/>
)
})
})
WORKS this.props.action is my mock
my deps:
{
"jest": "^23.6.0",
"preact-cli": "^2.2.1",
"preact-render-spy": "^1.3.0",
"preact": "^8.4.2"
}
any ideas?
thanks