Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Provide a Jest Transform #554
Comments
|
@therealparmesh great suggestion. I see that Jest can already do this when Babel is installed, though because Microbundle abstract Babel Jest likely doesn't detect it. So I guess you're saying it would be nice if there was a Microbundle-provided option here? If so, I agree! |
|
Precisely what I meant! FWIW, my current workaround is to have my Jest tests import from |
|
Any feedback on this? |
|
microbundle could save the configuration to the project root with a "This is autogenerated. Don't change it." If microbundle would come with a "public" Babel config, it would also be possible to put a eslint config to the root with just a |
|
If you're ending up here from Google, here's an approach that worked for me:
// Microbundle uses its own Babel config, so we need to make sure we use this only for tests
module.exports =
process.env.NODE_ENV === 'test'
? {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
'@babel/preset-react',
],
'@babel/preset-typescript',
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
],
}
: {}
"test": "NODE_ENV=test jest --coverage",
"test:no-coverage": "NODE_ENV=test jest",
"test:watch": "NODE_ENV=test jest --coverage --watch",
|

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

It may be convenient to expose something to consumers that will make it easier to use Jest - something like the default babel options (presets, plugins, etc.) or a transform module (see something like https://github.com/ActuallyACat/jest-esm-transformer).
This makes using syntax like
import/exportmuch easier for folks who use this amazing library for bundling and Jest for tests.Thank you!