1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var Test = require('../test');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | module.exports = function (suite) {
|
35 | var suites = [suite];
|
36 |
|
37 | suite.on('pre-require', function (context, file, mocha) {
|
38 | var common = require('./common')(suites, context, mocha);
|
39 |
|
40 | context.before = common.before;
|
41 | context.after = common.after;
|
42 | context.beforeEach = common.beforeEach;
|
43 | context.afterEach = common.afterEach;
|
44 | context.run = mocha.options.delay && common.runWithSuite(suite);
|
45 | |
46 |
|
47 |
|
48 |
|
49 | context.suite = function (title) {
|
50 | if (suites.length > 1) {
|
51 | suites.shift();
|
52 | }
|
53 | return common.suite.create({
|
54 | title: title,
|
55 | file: file,
|
56 | fn: false
|
57 | });
|
58 | };
|
59 |
|
60 | |
61 |
|
62 |
|
63 |
|
64 | context.suite.only = function (title) {
|
65 | if (suites.length > 1) {
|
66 | suites.shift();
|
67 | }
|
68 | return common.suite.only({
|
69 | title: title,
|
70 | file: file,
|
71 | fn: false
|
72 | });
|
73 | };
|
74 |
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | context.test = function (title, fn) {
|
82 | var test = new Test(title, fn);
|
83 | test.file = file;
|
84 | suites[0].addTest(test);
|
85 | return test;
|
86 | };
|
87 |
|
88 | |
89 |
|
90 |
|
91 |
|
92 | context.test.only = function (title, fn) {
|
93 | return common.test.only(mocha, context.test(title, fn));
|
94 | };
|
95 |
|
96 | context.test.skip = common.test.skip;
|
97 | context.test.retries = common.test.retries;
|
98 | });
|
99 | };
|