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 🦸
- Supports gets, sets, new, and invocation
- Supports nested everything
Perfect for snapshot testing mocks with Jest
Examples
Inspecting
const { mock, inspect } = require("mockital");
const Mock = mock();
Mock.a = "is this is amazing?";
const 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", []]]]]
]
]
]
];Stubbing values NEW
const { mock, when } = require("mockital");
const Mock = mock();
when("a", mock().a.b.c("1", "2", "3"), Mock);
Mock.a.b.c("1", "2", "3") === "a";