-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Haute-Conture 4.2+ uses mo-walk
.
There seem to be issues ( google search] in Node around dynamic imports. It seems to more prevalent with newer version of Node. Jest specifically will segfault on these. The line in question in mo-walk
is:
https://github.com/devinivy/mo-walk/blob/main/lib/index.js#L157
Steps to Reproduce
- Run a simple
hapipal
init as outlined in the Quick Start
npm init @hapipal my-project
cd ./my-project
npm install
- Inside
my-project
add the following route at test at the following paths:
// <root>/test/ping.test.js
const Server = require('../server');
// Start application before running the test case
let server = null;
beforeAll(async () => {
});
// Stop application after running the test case
afterAll(async () => {
if (server) {
await server.stop();
}
});
test('should ping tests', async () => {
server = await Server.deployment();
console.log('Server is running');
const options = {
method: 'GET',
url: '/ping',
};
const data = await server.inject(options);
expect(data.statusCode).toBe(200);
});
// <root>/lib/routes/ping.js
module.exports = {
method: 'GET',
path: '/ping',
options: {
auth: false,
handler: async (request, h) => h.response({ status: 'OK' }),
},
};
- Add Jest
npm i jest
- Add
test:jest
to thepackage.json
scripts area:"test:jest": "NODE_ENV=test jest --verbose",
- Run the test:
npm run test:jest test/ping.test.js
I also recommend clearing out your node_modules
and re-installing so you have a clean install.
This issue make it so that hapi-pal can't be used either as it uses HC, so this is a cascading effect. Lab doesn't seem to demonstrate this issue, however even though Jest does, I have also recreated this with Mocha.
Metadata
Metadata
Assignees
Labels
No labels