Skip to content

Commit

Permalink
fix: fixture path to support commonjs and esm (#19)
Browse files Browse the repository at this point in the history
* fix: fixture path to support commonjs and esm

Co-authored-by: Elangovan, Gobinath <[email protected]>
  • Loading branch information
sewnagP and Elangovan, Gobinath authored Apr 8, 2022
1 parent 9fa446b commit 28a7081
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ export function findComponentFixtures(
component = component.default || component;
const renderFn =
[".json", ".js"].indexOf(fixtureExtension) !== -1
? () => render(component, require(fixturePath))
: () => render(require(fixturePath));
? () => render(component, (require(fixturePath).default || require(fixturePath)))
: () => render(require(fixturePath).default || require(fixturePath));
return {
async toString(normalizer = defaultNormalizer) {
const result = await renderFn();
return defaultSerializer(normalizer(result.container));
},
get fixture() {
return require(fixturePath);
return (require(fixturePath).default || require(fixturePath));
},
path: fixturePath,
ext: fixtureExtension,
Expand Down

0 comments on commit 28a7081

Please sign in to comment.