1 | ;
|
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 |
|
21 | /**
|
22 | * Tap testing library
|
23 | * @external tap
|
24 | * @see {@link http://www.node-tap.org/}
|
25 | */
|
26 |
|
27 | const chaiLibrary = require('chai');
|
28 | const chaiAsPromisedLib = require('chai-as-promised');
|
29 | const sinonLibrary = require('sinon');
|
30 | const sinonTest = require('sinon-test');
|
31 | const tap = require('tap');
|
32 |
|
33 | sinonLibrary.test = sinonTest.configureTest(sinonLibrary);
|
34 | sinonLibrary.testCase = sinonTest.configureTestCase(sinonLibrary);
|
35 |
|
36 | /**
|
37 | * Sinon stubs/mocks/spies etc.
|
38 | * @returns {external:sinon} sinon object for mocking/stubing/spying
|
39 | */
|
40 | const getSinon = () => sinonLibrary;
|
41 |
|
42 | /**
|
43 | * Sinon sandbox
|
44 | * @returns {external:sinon.sandbox} sinon sandbox object for mocking/stubing/spying
|
45 | */
|
46 | const getSinonSandbox = () => sinonLibrary.sandbox.create();
|
47 | /**
|
48 | * Chai with promise support library
|
49 | * @returns {external:chai-as-promised} chai with support library
|
50 | */
|
51 | const getChai = () => {
|
52 | chaiLibrary.use(chaiAsPromisedLib);
|
53 | chaiLibrary.should();
|
54 | return chaiLibrary;
|
55 | };
|
56 |
|
57 | /**
|
58 | * Tap testing library
|
59 | * @returns {external:tap} tap testing library
|
60 | */
|
61 | const getTap = () => tap;
|
62 |
|
63 | module.exports = {
|
64 | getExpect: () => getChai().expect,
|
65 | getChai,
|
66 | getSinon,
|
67 | getSinonSandbox,
|
68 | getTap,
|
69 | };
|