Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freshly generated project has broken test on Windows #151

Closed
Cono52 opened this issue Nov 19, 2020 · 5 comments · Fixed by #154
Closed

Freshly generated project has broken test on Windows #151

Cono52 opened this issue Nov 19, 2020 · 5 comments · Fixed by #154
Assignees
Labels
bug Something isn't working

Comments

@Cono52
Copy link
Contributor

Cono52 commented Nov 19, 2020

Doesn't seem to be a problem on my Mac but decided to run on Windows in case everyone else wasn't.

I checked again, by pulling latest from master on both my machines -> rebuild -> re-add to global -> regenerate a test projects -> re-run tests

i guess it's related to jest dom not being added correctly?

@Cono52 Cono52 self-assigned this Nov 19, 2020
@threepointone
Copy link
Contributor

Oh hmm, yeah, looks like setupTests isn't being called properly.

@threepointone threepointone added the bug Something isn't working label Nov 19, 2020
@Cono52
Copy link
Contributor Author

Cono52 commented Nov 19, 2020

I found it's related to the globby in the craco.config.js used to find the setupTests.ts

setupFilesAfterEnv: globby.sync(
[`${absoluteModularGlobalConfigsPath}/setupTests.{js,ts,tsx}`],
{
cwd: process.cwd(),

seems globby has some catches on Windows and produces nothing when searching any patterns

sindresorhus/globby#155

will look into workarounds

@threepointone
Copy link
Contributor

threepointone commented Nov 20, 2020

We could just not use globby here

setupFilesAfterEnv: globby.sync(
[`${absoluteModularGlobalConfigsPath}/setupTests.{js,ts,tsx}`],

maybe like...

["setupTests.js", "setupTests.ts", "setupTests.tsx"]
  .map((p) => path.join(absoluteModularGlobalConfigsPath, p))
  .filter((p) => fs.existsSync(p));

@threepointone
Copy link
Contributor

We should also run our CI tests on windows, I'll look into that later.

@Cono52
Copy link
Contributor Author

Cono52 commented Nov 20, 2020

Your code sliced worked in the above case but it was handy to keep some globing to keep giving those nice warnings about other "setupTests" files that might be found somewhere randomly in the package i.e.

console.warn(
"A setupTests file was found within an app's `src/` directory:",
perPackageSetupTests.join(', '),
);
console.warn(
'Modular projects should store all test setup at the root of the project (e.g. `modular/setupTests.{js,ts,tsx}`).',
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants