Morpheus

Export your Insomnia workspace and test it in command line.

demo

Features

  • Env variables
  • Basic Auth
  • JWT
  • GET, POST, PUT, PATCH, DELETE, HEAD requests
  • GraphQL
  • Custom headers
  • Query params
  • Chaining Requests
  • OAuth
  • OAuth2
  • File upload

Installation

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: []
};

Usage

By default Morpheus search look for a file named /Insomnia.*\.json/i

{
  "scripts": {
    "test:api": "jest --config=morpheus.config.js"
  }
}

Example

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",
}

To do

In file.ts take the most recent file using fs.statSync is there are multiples Insomnia files