Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Aug 22, 2023
1 parent fc85365 commit e19fd0c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1004,4 +1004,32 @@ describe(`Plug'n'Play - ESM`, () => {
),
);
});

it(
`should use the commonjs resolver in commonjs files imported from ESM`,
makeTemporaryEnv(
{
type: `module`,
},
async ({ path, run, source }) => {

Check failure on line 1014 in packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

There should be no space after '{'

Check failure on line 1014 in packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

There should be no space before '}'
await xfs.writeFilePromise(ppath.join(path, `foo.js`), `import './bar.cjs';`);
await xfs.writeFilePromise(
ppath.join(path, `bar.cjs`),
`
require('module')._extensions['.custom'] = require('module')._extensions['.js'];
require('./baz');
`

Check failure on line 1021 in packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Missing trailing comma
);
await xfs.writeFilePromise(ppath.join(path, `baz.custom`), `console.log(42);`);

await expect(run(`install`)).resolves.toMatchObject({ code: 0 });

Check failure on line 1025 in packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

There should be no space after '{'

Check failure on line 1025 in packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

There should be no space before '}'

await expect(run(`node`, `./foo.js`)).resolves.toMatchObject({
code: 0,
stdout: `42\n`,
stderr: '',

Check failure on line 1030 in packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Strings must use backtick
});
}

Check failure on line 1032 in packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Missing trailing comma
)

Check failure on line 1033 in packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Missing trailing comma
);
});

0 comments on commit e19fd0c

Please sign in to comment.