Currently, I am thinking of writing a test using a combination of gulp+babel+mocha.
The production code is located under the root/src/modules directory.
I would like to place the test code under root/test/modules in the same configuration as the production code.
In this case, the test code contains
import shut from '../../../(repeatUntilRoot...)/src/mosules/(pathToSUT...)'
It is very complicated to write
Webpack is used to build production code
import someModule from 'modules/path/to/module'
It can be resolved as shown in .
Would it be possible to call the module under test from the test code using the same description as the above production code without using Webpack during the test?
It is possible by setting it as an environment variable. exportNODE_PATH=/path/to/project/root/src
How about using wavy?The package.json
location is treated as through
.
mkdir foo & cd foo
echo'module.exports="foo"'>index.js
npm install wavy
node-e "console.log(require('~/index.js')')"
# foo
© 2024 OneMinuteCode. All rights reserved.