Closed inggil2407 closed 6 years ago
When I try to start karma unit testing, console shows errors: Module not found: Error: Can't resolve '@ app/env' in...
P.S. Compiling and building works as it should (ionic serve, ionic build cordova, ionic cordova compile, ...).
Hi,
You need to tell webpack where to find (resolve) the app/env
files...
I guess you have a webpack.test.js
somewhere, if so, update the resolve
block to look like this.
resolve: {
alias: {
'@app/env': path.resolve(environmentPath('dev'))
},
extensions: ['.ts', '.js']
},
...
Define your environmentPath
function to return the path to your env config as in the README of the project. You can even extract it into a env-helper.js
file outside of the webpack configs to avoid code duplication, and require your helper.
Hope it helps ;)
Thank you very much!
Srdačan pozdrav,
Srđan Jovanović | Developer Manager Emisia Consulting, Kragujevac, Serbia
On Tue, Jan 23, 2018 at 8:04 PM, Alpha Barry notifications@github.com wrote:
Hi,
You need to tell webpack where to find (resolve) the app/env files... I guess you have a webpack.test.js somewhere, if so, update the resolve block to look like this.
resolve: { alias: { '@app/env': path.resolve(environmentPath('dev')) }, extensions: ['.ts', '.js'] }, ...
Define your environmentPath function to return the path to your env config as in the README of the project. You can even extract it into a env-helper.js file outside of the webpack configs to avoid code duplication, and require your helper.
Hope it helps ;)
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gshigeto/ionic-environment-variables/issues/20#issuecomment-359895554, or mute the thread https://github.com/notifications/unsubscribe-auth/Af_RwEVpIzqsQxpXwKW0nohgt1s3SAMrks5tNi1CgaJpZM4RhlQw .
I am going to close this as it seems to be resolved. Thanks!
@gshigeto This info should probably be added to the README as it's likely the majority of people will be using unit tests and this needs to be inplace in order to make them work.
Thanks god I found this, really...
I want to create unit testing but, always get "Uncaught Error: Cannot find module "@app/env""