Just wanted to verify if we're exporting an object, but the test is failing as shown below:
import * as Foo from './foo';
describe('Foo', () => {
test('should export an object', () => {
expect(Foo).toBeInstanceOf(Object);
});
});
encountering this error message:
https://i.sstatic.net/j9FoR.png
However, I found a workaround using typeof
:
import * as Foo from './foo';
describe('Foo', () => {
test('should export an object', () => {
- expect(Foo).toBeInstanceOf(Object);
+ expect(typeof LivingAppsCoreReact).toEqual('object');
});
});
I am curious to know why Jest doesn't recognize the Object
constructor as... the Object
constructor.
Confirmed that the object is indeed exporting the correct keys ✅
Environment details:
$» npm ls jest 1 ↵
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="04697d2974766b6e61677044342a37352a31">[email protected]</a>
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="771d12040337454e59445946">[email protected]</a>
└─┬ <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9aeee9b7f0ffe9eedaa8a3b4aab4a9">[email protected]</a>
└── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="28424d5b5c681a11061b0619">[email protected]</a> deduped