Export your Insomnia workspace and test it in command line.
- Env variables
- Basic Auth
- JWT
- GET, POST, PUT, PATCH, DELETE, HEAD requests
- GraphQL
- Custom headers
- Query params
- Chaining Requests
- OAuth
- OAuth2
- File upload
yarn add -DE @lano/morpheus jest
Create a morpheus.config.js
and put this content
// morpheus.config.js
module.exports = {
verbose: true,
rootDir: __dirname,
snapshotResolver: "<rootDir>/node_modules/@lano/morpheus/snapshotResolver.js",
testMatch: ["<rootDir>/node_modules/@lano/morpheus/tests/morpheus.spec.js"],
testPathIgnorePatterns: []
};
By default Morpheus search look for a file named /Insomnia.*\.json/i
{
"scripts": {
"test:api": "jest --config=morpheus.config.js"
}
}
The generated snapshot will look like the following. Keep in mind that the date
header is removed to not break the snapshots.
Object {
"body": "OK",
"description": "",
"headers": Object {
"connection": "close",
"content-length": "2",
"content-type": "text/plain; charset=utf-8",
},
"statusCode": 200,
"url": "http://localhost:5000/auth/basic",
}
In file.ts
take the most recent file using fs.statSync is there are multiples Insomnia files