-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
feat: Add support for the jest.config.ts
configuration file
#10564
Conversation
note the "export =" should never be use. It requires the tsconfig.json to use a specific output (commonjs), which may not be what your project intends. "export default" is the correct way, for both async/sync |
This was my thought as well, but if I'm using |
|
I've tried to add the interlop function but I had the same result. I will see if I have the same problem with the new compilation method. |
Was this the interlop function?
That's what we've got in I think that will break for |
what i generally do is const myconfig = require('.....')
if( myconfig.default ) {
if(typeof(myconfig.default) === 'function') return Promise.resolve(myconfig.default())
return Promise.resolve(myconfig.default)
}
if(typeof(myconfig) === 'function') return Promise.resolve(myconfig())
return Promise.resolve(myconfig) that should handle just about every way a module would be exported with a "function". I'm not partial to empty called functions, so I would generally pass in the object of the code, jest or whatever, so that the configuration file can make decisions based on things like default settings or version specific code. |
@dl748 we shouldn't need to do any of that extra checking unless this PR is also adding the ability to export a function, as that's something Effectively what we're wanting to do here is handle just the |
Yes I know, i'm just explaining how i've implemented things like interpret, for max compatibility with targeted languages like ES6 and TS interpret is far more lightweight than importing the entire typescript library. |
… of the `jest.config.ts` functionality
… 'ReferenceError: globalThis is not defined' on Node 10.x (nrwl/nx#3776 (comment))
via see https://github.com/DimensionDev/Maskbook/blob/9b975f30/jest.config.js#L12-L17 |
@Gamote may be need auto detect when the user uses the pure esmodule library or e.q: |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Allow developers to define the configuration file using Typescript. This allow a project to be written only in TypeScript and helps with auto-suggestions.
This PR resolves #9636.
Example
docs
andCHANGELOG.md
file were updated to reflect these changes.Test plan
Tests have been added/updated to check for this behaviour and some messages were updated to indicate to the user about the new supported extension (
.ts
).CC: @SimenB