I have a mapModule
where I import components and export them:
JavaScript
x
6
1
import ComponentName from '../components/ComponentName';
2
3
export default {
4
name: ComponentName,
5
};
6
How can I test that mapModule
has the correct exported keys, values and that they are not null or undefined?
Advertisement
Answer
In version 23.3.0 of jest,
JavaScript
1
2
1
expect(string).toMatch(string)
2
expects a string.
Use:
JavaScript
1
4
1
const expected = { name:'component name' }
2
const actual = { name: 'component name', type: 'form' }
3
expect(actual).toMatchObject(expected)
4
result is passing test