JSPM

  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q26585F
  • License unlicense

mock anything

Package Exports

  • mockital

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mockital) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MOCKITAL 🦸

Build Status Coverage Status

  • Supports gets, sets, new, and invocation
  • Supports nested everything

More utilities are coming for inspecting/asserting/stubbing

Perfect for snapshot testing mocks with Jest

Examples

import { mock, inspect } from "mockital";

let Mock = mock();

Mock.a = "is this is amazing?";

let wow = new Mock.b.c["c"](1, "2", [1, 2]);

wow.d.e(1, 2, 3).f = "this is amazing";

JSON.stringify(inspect(Mock)) ===
  [
    ["set", "a", "is this is amazing?", []],
    [
      "get",
      "b",
      [
        [
          "get",
          "c",
          [
            [
              "get",
              "c",
              [
                [
                  "new",
                  [1, "2", [1, 2]],
                  [
                    [
                      "get",
                      "d",
                      [
                        [
                          "get",
                          "e",
                          [
                            [
                              "apply",
                              [1, 2, 3],
                              [["set", "f", "this is amazing", []]]
                            ]
                          ]
                        ]
                      ]
                    ]
                  ]
                ]
              ]
            ]
          ]
        ]
      ]
    ]
  ];
JSON.stringify(inspect(wow)) ===
  [
    [
      "get",
      "d",
      [
        [
          "get",
          "e",
          [["apply", [1, 2, 3], [["set", "f", "this is amazing", []]]]]
        ]
      ]
    ]
  ];