-
Notifications
You must be signed in to change notification settings - Fork 33
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 JS config handling to webpack and jest configs #515
Changes from all commits
07285fe
a65980f
9661ada
26de6b7
a3cc567
d664423
54e8a46
0876775
9acebc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,16 @@ const fs = require('fs'); | |
|
||
const presets = require('../lib/presets'); | ||
|
||
// This assigns the envConfigPath filepath based on whether env.config exists, otherwise it uses the fallback filepath. | ||
// If both env.config.js and env.config.jsx files exist, then the former will be used to populate the Config Document. | ||
let envConfigPath = path.resolve(__dirname, './jest/fallback.env.config.js'); | ||
const appEnvConfigPath = path.resolve(process.cwd(), './env.config.js'); | ||
const appEnvConfigPathJs = path.resolve(process.cwd(), './env.config.js'); | ||
const appEnvConfigPathJsx = path.resolve(process.cwd(), './env.config.jsx'); | ||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [curious] Is there a chance someone may want to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would! ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use https://www.npmjs.com/package/glob to find the file with regex instead? It is easier to improve in the future. |
||
|
||
if (fs.existsSync(appEnvConfigPath)) { | ||
envConfigPath = appEnvConfigPath; | ||
if (fs.existsSync(appEnvConfigPathJs)) { | ||
envConfigPath = appEnvConfigPathJs; | ||
} else if (fs.existsSync(appEnvConfigPathJsx)) { | ||
envConfigPath = appEnvConfigPathJsx; | ||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a specific reason this logic prioritizes |
||
} | ||
|
||
module.exports = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that an
env.config.js
will now be required for tests to run successfully?Maybe it already is and I just missed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually,
env.config.js
isn't required to run tests, but if there are any env variables or configuration in the env.config.js file that should be used for tests, this is what will be needed in thesetupTest.js
file.