eslint-plugin-import-x
eslint-plugin-import-x copied to clipboard
Failing test on master: "yarn pnp > should just work"
When I pull down the latest master and run yarn && yarn test on my Mac, I get:
FAIL test/fixtures.spec.ts
● yarn pnp › should just work
expect(received).toMatchSnapshot()
Snapshot name: `yarn pnp should just work 1`
- Snapshot - 2
+ Received + 9
{
- "exitCode": 0,
+ "exitCode": 1,
"stderr": "",
- "stdout": "",
+ "stdout": "<CLR=0><CLR=0>
+ <CLR=0><CLR=4>/Users/trevor.burnham/code/eslint-plugin-import-x/test/fixtures/yarn-pnp/index.js<CLR=24><CLR=0>
+ <CLR=0> <CLR=2>1:17<CLR=22> <CLR=31>error<CLR=39> Unable to resolve path to module 'pnpapi' <CLR=2>import-x/no-unresolved<CLR=22><CLR=0>
+ <CLR=0> <CLR=2>3:17<CLR=22> <CLR=31>error<CLR=39> Unable to resolve path to module 'epix-oxc/add' <CLR=2>import-x/no-unresolved<CLR=22><CLR=0>
+ <CLR=0><CLR=0>
+ <CLR=0><CLR=31><CLR=BOLD>✖ 2 problems (2 errors, 0 warnings)<CLR=22><CLR=39><CLR=0>
+ <CLR=0><CLR=31><CLR=22,BOLD><CLR=39><CLR=0>
+ ",
}
10 | await exec('yarn', ['install', '--immutable'], execOptions)
11 | const result = await exec('yarn', ['lint'], execOptions)
> 12 | expect(result).toMatchSnapshot()
| ^
13 | }, 10_000)
14 | })
15 |
git bisect tells me that #243 introduced the issue.
Did you enable corepack? Otherwise the global yarn could be used, which is usually yarn v1.
It turns out the test passes if I run yarn build before yarn test.
I can close the issue if you like, but it seems unusual to me that the tests for a TypeScript project would implicitly depend on the build. 🤷🏻♂️
This should be related to https://github.com/un-ts/eslint-plugin-import-x/blob/96c08b49c60bd43c984f11809953ed03d0f5781c/test/fixtures/yarn-pnp/package.json#L15
It's a kind of e2e test case, maybe I should split from unit tests.
PR welcome if you have good ideas to improve this. Move this test case into test:e2e for example.
Or it should only be enabled with test-compiled which would be much easier.
I use conditional exports to run tests against uncompiled and compiled versions of the code:
"exports": {
".": {
"epix": "./src/index.ts",
"default": "./lib/index.js"
}
}
then you can set testEnvironmentOptions.customExportConditions in jest.config, and dump the module name mapper.
edit: ahh, no, because that test is running as a full integration test eslint obviously can't handle the raw ts of this plugin. oh well