diff --git a/src/index.ts b/src/index.ts index bfac389..2c10382 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,7 +31,7 @@ export function findComponentFixtures( const componentName = inferName(componentPath); const fixturesPath = path.join(path.dirname(componentPath), fixtureDir); const fixtures = glob - .sync("*.{json,marko}", { cwd: fixturesPath }) + .sync("*.{json,marko,js}", { cwd: fixturesPath }) .map((fixtureRelativePath: string) => { const fixturePath = path.join(fixturesPath, fixtureRelativePath); const fixtureExtension = path.extname(fixturePath); @@ -39,7 +39,7 @@ export function findComponentFixtures( .basename(fixturePath) .slice(0, -1 * fixtureExtension.length); const renderFn = - fixtureExtension === ".json" + [".json", ".js"].indexOf(fixtureExtension) !== -1 ? () => render(require(componentPath), require(fixturePath)) : () => render(require(fixturePath)); return { @@ -56,13 +56,10 @@ export function findComponentFixtures( render: renderFn }; }) - .reduce( - (lookup, current) => { - lookup[current.name] = current; - return lookup; - }, - {} as ComponentFixtures["fixtures"] - ); + .reduce((lookup, current) => { + lookup[current.name] = current; + return lookup; + }, {} as ComponentFixtures["fixtures"]); if (Object.keys(fixtures).length) { return { get component() { diff --git a/test/components/container/fixtures/data.html b/test/components/container/fixtures/data.html new file mode 100644 index 0000000..ce3e0b6 --- /dev/null +++ b/test/components/container/fixtures/data.html @@ -0,0 +1,8 @@ +
+ Hello +
+ Async content +Hello
"), + model: Promise.resolve("Async content") +}; diff --git a/test/components/container/index.marko b/test/components/container/index.marko new file mode 100644 index 0000000..a35cf03 --- /dev/null +++ b/test/components/container/index.marko @@ -0,0 +1,9 @@ +