UNPKG

1.33 kBJavaScriptView Raw
1'use strict';
2
3/**
4 * Chai assert library
5 * @external chai
6 * @see {@link http://chaijs.com/}
7 */
8
9 /**
10 * Chai promise assert library
11 * @external chai-as-promised
12 * @see {@link https://github.com/domenic/chai-as-promised}
13 */
14
15/**
16 * Standalone and test framework agnostic JavaScript test spies, stubs and mocks
17 * @external sinon
18 * @see {@link https://github.com/sinonjs/sinon}
19 */
20
21const chaiLibrary = require('chai');
22const chaiAsPromisedLib = require('chai-as-promised');
23const sinonLibrary = require('sinon');
24const sinonTest = require('sinon-test');
25
26sinonLibrary.test = sinonTest.configureTest(sinonLibrary);
27sinonLibrary.testCase = sinonTest.configureTestCase(sinonLibrary);
28
29/**
30 * Sinon stubs/mocks/spies etc.
31 * @returns {external:sinon} sinon object for mocking/stubing/spying
32 */
33const getSinon = () => sinonLibrary;
34
35/**
36 * Sinon sandbox
37 * @returns {external:sinon.sandbox} sinon sandbox object for mocking/stubing/spying
38 */
39const getSinonSandbox = () => sinonLibrary.sandbox.create();
40/**
41 * Chai with promise support library
42 * @returns {external:chai-as-promised} chai with support library
43 */
44const getChai = () => {
45 chaiLibrary.use(chaiAsPromisedLib);
46 chaiLibrary.should();
47 return chaiLibrary;
48};
49
50module.exports = {
51 getExpect: () => getChai().expect,
52 getChai,
53 getSinon,
54 getSinonSandbox,
55};