tsdx: test/ dir is in `include`, non-spec TS files (e.g. test utils) break build with v0.13 rootDir: `./src`

Current Behavior

Prior to v0.13 #504 , I could put a file into my test folder that contained utility code for tests and it would get compiled without a problem.

test/TestUtils.tsx

Now, when I tsdx build, I see this error:

rpt2: options error TS6059: File '/mui-rff/test/TestUtils.tsx' is not under 'rootDir' '/mui-rff/src'. 'rootDir' is expected to contain all source files.

Expected behavior

I have a place to put utility code for tests.

Suggested solution(s)

No idea, but you have a list of 3rd parties using this project and it would be nice if you would start to test future versions of tsdx against these projects to see if you break peoples stuff and can then use that to find out how to tell people how to fix their broken stuff.

Your environment

Software Version(s)
TSDX v0.13
TypeScript 3.8.3
npm/Yarn 6.13.7 / 1.22.4
Node v13.11.0
Operating System OSX Catalina

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 43 (23 by maintainers)

Most upvoted comments

For the record, I wasn’t poking at TSDX, I was poking at users of TSDX. 😉

I do notice that the build is faster now. =)

  • mui-rff, which I think is based off our templates (correct me if I’m wrong) and uses test in include, had published a test dir in 2.0.3 and prior, but not in 2.0.4 which uses TSDX v0.13

It is based off a template several versions ago.

Type-checking and editor type-checking are more difficult; while tsc -p can be used to choose a tsconfig.json, the editor might only use the exact tsconfig.json of the directory – see #84

So maybe it makes sense for root tsconfig.json to have include: ['**'] for linting and type-checking via tsdx lint and tsc --noEmit as well as zero-config editor integration. And then we have a tsconfig.build.json that’s specifically for building, has file: ['src/index.ts'] and maybe include: ['types/'] and would be used by default by tsdx build. tsconfig.json could extend tsconfig.build.json so that it’s the source of truth.

Not sure how Storybook would interact with this however, c.f. #641

Thank you both for the back and forth.

This is a bad bug. It is also preventing Formik from using latest release. We need to fix this ASAP, lots of folks have test utils in separate files, definitely falls under 80% of all TS projects IMHO.