sxy-test-runner 1.3.5 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/files.js +20 -0
- package/dist/cli/files.unitTest.js +246 -0
- package/dist/cli/index.js +3 -4
- package/dist/cli/watch.js +14 -0
- package/package.json +3 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
// import { watch } from './watch.js'
|
|
3
|
+
|
|
4
|
+
// // args: string[]
|
|
5
|
+
// export function files() {
|
|
6
|
+
// //const args = global.commandLineArguments
|
|
7
|
+
|
|
8
|
+
// if (args.length === 0) {
|
|
9
|
+
// return console.log(
|
|
10
|
+
// '`sxy-test-runner files` requires an argument which is a global pattern of test files to run'
|
|
11
|
+
// )
|
|
12
|
+
// }
|
|
13
|
+
// if (args.length > 1) {
|
|
14
|
+
// return console.log(
|
|
15
|
+
// '`sxy-test-runner files` only accepts 1 argument at present'
|
|
16
|
+
// )
|
|
17
|
+
// }
|
|
18
|
+
// const pattern = args[0]
|
|
19
|
+
// watch()
|
|
20
|
+
// }
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
|
|
2
|
+
// import figures from 'figures'
|
|
3
|
+
|
|
4
|
+
// //import { applyConfigDefaults } from './lib/applyConfigDefaults.js'
|
|
5
|
+
// import { files } from './files.js'
|
|
6
|
+
|
|
7
|
+
// mochaDescribe('files command', function() {
|
|
8
|
+
|
|
9
|
+
// mochaIt('should fail with empty args', async function() {
|
|
10
|
+
// this.timeout(10000)
|
|
11
|
+
|
|
12
|
+
// const originalConsoleLog = console.log
|
|
13
|
+
// let consoleLogBuffer = ''
|
|
14
|
+
// console.log = sync(function testLog(...texts) {
|
|
15
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
16
|
+
// })
|
|
17
|
+
|
|
18
|
+
// global.commandLineArguments = [
|
|
19
|
+
// '--config',
|
|
20
|
+
// 'unitTesting/watch/sxy-test-runner.config.js'
|
|
21
|
+
// ]
|
|
22
|
+
|
|
23
|
+
// promise( files([]) )
|
|
24
|
+
// await new Promise( (resolve, reject) => { setTimeout(resolve, 8000) } )
|
|
25
|
+
|
|
26
|
+
// console.log = originalConsoleLog
|
|
27
|
+
|
|
28
|
+
// //console.log(consoleLogBuffer)
|
|
29
|
+
// consoleLogBuffer.should.include( 'requires an argument' )
|
|
30
|
+
// })
|
|
31
|
+
|
|
32
|
+
// mochaIt('should fail with too many args', async function() {
|
|
33
|
+
// this.timeout(10000)
|
|
34
|
+
|
|
35
|
+
// const originalConsoleLog = console.log
|
|
36
|
+
// let consoleLogBuffer = ''
|
|
37
|
+
// console.log = sync(function testLog(...texts) {
|
|
38
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
39
|
+
// })
|
|
40
|
+
|
|
41
|
+
// global.commandLineArguments = [
|
|
42
|
+
// '--config',
|
|
43
|
+
// 'unitTesting/watch/sxy-test-runner.config.js'
|
|
44
|
+
// ]
|
|
45
|
+
|
|
46
|
+
// promise( files(['a', 'b']) )
|
|
47
|
+
// await new Promise( (resolve, reject) => { setTimeout(resolve, 8000) } )
|
|
48
|
+
|
|
49
|
+
// console.log = originalConsoleLog
|
|
50
|
+
|
|
51
|
+
// //console.log(consoleLogBuffer)
|
|
52
|
+
// consoleLogBuffer.should.include( 'only accepts 1 argument' )
|
|
53
|
+
// })
|
|
54
|
+
|
|
55
|
+
// mochaIt('should run tests and output results and display correct tallies', async function() {
|
|
56
|
+
// this.timeout(10000)
|
|
57
|
+
|
|
58
|
+
// const originalConsoleLog = console.log
|
|
59
|
+
// let consoleLogBuffer = ''
|
|
60
|
+
// console.log = sync(function testLog(...texts) {
|
|
61
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
62
|
+
// })
|
|
63
|
+
|
|
64
|
+
// global.commandLineArguments = [
|
|
65
|
+
// '--config',
|
|
66
|
+
// 'unitTesting/watch/sxy-test-runner.config.js'
|
|
67
|
+
// ]
|
|
68
|
+
|
|
69
|
+
// promise( files(['**/1.test.js']) )
|
|
70
|
+
// await new Promise( (resolve, reject) => { setTimeout(resolve, 8000) } )
|
|
71
|
+
|
|
72
|
+
// console.log = originalConsoleLog
|
|
73
|
+
|
|
74
|
+
// //console.log(consoleLogBuffer)
|
|
75
|
+
|
|
76
|
+
// const testFileName = `unitTesting/watch/1.test.js`
|
|
77
|
+
// const thing = 'Sample test 1'
|
|
78
|
+
// const should = '1 should equal 1'
|
|
79
|
+
|
|
80
|
+
// console.log(consoleLogBuffer)
|
|
81
|
+
|
|
82
|
+
// consoleLogBuffer.should.include( testFileName )
|
|
83
|
+
// consoleLogBuffer.should.include( thing )
|
|
84
|
+
// consoleLogBuffer.should.include( should )
|
|
85
|
+
// consoleLogBuffer.should.include( figures.tick )
|
|
86
|
+
|
|
87
|
+
// consoleLogBuffer.should.include( 'Tests: 1/1' )
|
|
88
|
+
// consoleLogBuffer.should.include( 'Items: 1/1' )
|
|
89
|
+
// consoleLogBuffer.should.include( 'Test Files: 1/1' )
|
|
90
|
+
|
|
91
|
+
// })
|
|
92
|
+
|
|
93
|
+
// /*
|
|
94
|
+
// mochaIt('should run tests and output results and display correct tallies', async function() {
|
|
95
|
+
// this.timeout(10000)
|
|
96
|
+
|
|
97
|
+
// const originalConsoleLog = console.log
|
|
98
|
+
// let consoleLogBuffer = ''
|
|
99
|
+
// console.log = sync(function testLog(...texts) {
|
|
100
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
101
|
+
// })
|
|
102
|
+
|
|
103
|
+
// global.commandLineArguments = [
|
|
104
|
+
// '--config',
|
|
105
|
+
// 'unitTesting/watch/sxy-test-runner.config.js'
|
|
106
|
+
// ]
|
|
107
|
+
|
|
108
|
+
// promise( watch() )
|
|
109
|
+
// await new Promise( (resolve, reject) => { setTimeout(resolve, 8000) } )
|
|
110
|
+
|
|
111
|
+
// console.log = originalConsoleLog
|
|
112
|
+
|
|
113
|
+
// //console.log(consoleLogBuffer)
|
|
114
|
+
|
|
115
|
+
// const testFileName = `unitTesting/watch/1.test.js`
|
|
116
|
+
// const thing = 'Sample test 1'
|
|
117
|
+
// const should = '1 should equal 1'
|
|
118
|
+
|
|
119
|
+
// consoleLogBuffer.should.include( testFileName )
|
|
120
|
+
// consoleLogBuffer.should.include( thing )
|
|
121
|
+
// consoleLogBuffer.should.include( should )
|
|
122
|
+
// consoleLogBuffer.should.include( figures.tick )
|
|
123
|
+
|
|
124
|
+
// consoleLogBuffer.should.include( 'Tests: 3/3' )
|
|
125
|
+
// consoleLogBuffer.should.include( 'Items: 2/2' )
|
|
126
|
+
// consoleLogBuffer.should.include( 'Test Files: 2/2' )
|
|
127
|
+
|
|
128
|
+
// })
|
|
129
|
+
|
|
130
|
+
// mochaIt('should run tests and display correct tallies', async function() {
|
|
131
|
+
// this.timeout(10000)
|
|
132
|
+
|
|
133
|
+
// const originalConsoleLog = console.log
|
|
134
|
+
// let consoleLogBuffer = ''
|
|
135
|
+
// console.log = sync(function testLog(...texts) {
|
|
136
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
137
|
+
// })
|
|
138
|
+
|
|
139
|
+
// global.commandLineArguments = [
|
|
140
|
+
// '--config',
|
|
141
|
+
// 'unitTesting/watch/sxy-test-runner.config.js'
|
|
142
|
+
// ]
|
|
143
|
+
|
|
144
|
+
// promise( watch() )
|
|
145
|
+
// await new Promise( (resolve, reject) => { setTimeout(resolve, 8000) } )
|
|
146
|
+
|
|
147
|
+
// console.log = originalConsoleLog
|
|
148
|
+
|
|
149
|
+
// //console.log(consoleLogBuffer)
|
|
150
|
+
|
|
151
|
+
// const testFileName = `unitTesting/watch/1.test.js`
|
|
152
|
+
// const thing = 'Sample test 1'
|
|
153
|
+
// const should = '1 should equal 1'
|
|
154
|
+
|
|
155
|
+
// consoleLogBuffer.should.include( testFileName )
|
|
156
|
+
// consoleLogBuffer.should.include( thing )
|
|
157
|
+
// consoleLogBuffer.should.include( should )
|
|
158
|
+
// consoleLogBuffer.should.include( figures.tick )
|
|
159
|
+
|
|
160
|
+
// })
|
|
161
|
+
|
|
162
|
+
// mochaIt('should warn us when there are no tests', async function() {
|
|
163
|
+
// this.timeout(6000)
|
|
164
|
+
|
|
165
|
+
// const originalConsoleLog = console.log
|
|
166
|
+
// let consoleLogBuffer = ''
|
|
167
|
+
// console.log = sync(function testLog(...texts) {
|
|
168
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
169
|
+
// })
|
|
170
|
+
|
|
171
|
+
// global.commandLineArguments = [
|
|
172
|
+
// '--config',
|
|
173
|
+
// 'sxy-test-runner.no-tests.config.js'
|
|
174
|
+
// ]
|
|
175
|
+
|
|
176
|
+
// promise( watch() )
|
|
177
|
+
// await new Promise( (resolve, reject) => { setTimeout(resolve, 4000) } )
|
|
178
|
+
|
|
179
|
+
// console.log = originalConsoleLog
|
|
180
|
+
|
|
181
|
+
// //console.log('saved console.log output:')
|
|
182
|
+
// //console.log(consoleLogBuffer)
|
|
183
|
+
|
|
184
|
+
// consoleLogBuffer.should.include( 'no tests found' )
|
|
185
|
+
// consoleLogBuffer.should.not.include( 'describing' )
|
|
186
|
+
|
|
187
|
+
// })
|
|
188
|
+
|
|
189
|
+
// mochaIt('should not run tests when asked not to run initial tests', async function() {
|
|
190
|
+
// this.timeout(6000)
|
|
191
|
+
|
|
192
|
+
// const originalConsoleLog = console.log
|
|
193
|
+
// let consoleLogBuffer = ''
|
|
194
|
+
// console.log = sync(function testLog(...texts) {
|
|
195
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
196
|
+
// })
|
|
197
|
+
|
|
198
|
+
// global.commandLineArguments = [
|
|
199
|
+
// '--config',
|
|
200
|
+
// 'sxy-test-runner.no-initial-tests.config.js'
|
|
201
|
+
// ]
|
|
202
|
+
|
|
203
|
+
// promise( watch() )
|
|
204
|
+
// await new Promise( (resolve, reject) => { setTimeout(resolve, 4000) } )
|
|
205
|
+
|
|
206
|
+
// console.log = originalConsoleLog
|
|
207
|
+
|
|
208
|
+
// //console.log('saved console.log output:')
|
|
209
|
+
// //console.log(consoleLogBuffer)
|
|
210
|
+
|
|
211
|
+
// //consoleLogBuffer.should.not.include( 'no tests found' ) // not sure - removing for now
|
|
212
|
+
// consoleLogBuffer.should.not.include( 'running initial tests' )
|
|
213
|
+
// consoleLogBuffer.should.not.include( 'describing' )
|
|
214
|
+
// consoleLogBuffer.should.include( 'watching' )
|
|
215
|
+
|
|
216
|
+
// })
|
|
217
|
+
|
|
218
|
+
// mochaIt('setup function and setup file from the config should have run', async function() {
|
|
219
|
+
// this.timeout(6000)
|
|
220
|
+
|
|
221
|
+
// global.configBasedSetupFunctionRan = false
|
|
222
|
+
// global.watchSetupFileHasRun = false
|
|
223
|
+
|
|
224
|
+
// const originalConsoleLog = console.log
|
|
225
|
+
// let consoleLogBuffer = ''
|
|
226
|
+
// console.log = sync(function testLog(...texts) {
|
|
227
|
+
// consoleLogBuffer += texts.join(' ') + '\n'
|
|
228
|
+
// })
|
|
229
|
+
|
|
230
|
+
// global.commandLineArguments = [
|
|
231
|
+
// '--config',
|
|
232
|
+
// 'sxy-test-runner.setup-tasks.config.js'
|
|
233
|
+
// ]
|
|
234
|
+
|
|
235
|
+
// promise( watch() )
|
|
236
|
+
// await new Promise( (resolve, reject) => {
|
|
237
|
+
// setTimeout(resolve, 2000)
|
|
238
|
+
// } )
|
|
239
|
+
|
|
240
|
+
// console.log = originalConsoleLog
|
|
241
|
+
|
|
242
|
+
// global.configBasedSetupFunctionRan.should.equal(true)
|
|
243
|
+
// global.watchSetupFileHasRun.should.equal(true)
|
|
244
|
+
|
|
245
|
+
// })*/
|
|
246
|
+
// })
|
package/dist/cli/index.js
CHANGED
|
@@ -8,18 +8,17 @@ if (args.length > 0) {
|
|
|
8
8
|
const command = args[0];
|
|
9
9
|
switch (command) {
|
|
10
10
|
case 'init':
|
|
11
|
-
await doCommand(command, await args.slice(1));
|
|
12
|
-
break;
|
|
13
11
|
case 'once':
|
|
14
|
-
await doCommand(command, await args.slice(1));
|
|
15
|
-
break;
|
|
16
12
|
case 'watch':
|
|
13
|
+
//case 'files':
|
|
17
14
|
await doCommand(command, await args.slice(1));
|
|
18
15
|
break;
|
|
19
16
|
default:
|
|
17
|
+
//console.log('watch 1 args', args)
|
|
20
18
|
await doCommand('watch', args);
|
|
21
19
|
}
|
|
22
20
|
} else {
|
|
21
|
+
//console.log('watch 2 args', args)
|
|
23
22
|
await doCommand('watch', args);
|
|
24
23
|
}
|
|
25
24
|
async function doCommand(command, args) {
|
package/dist/cli/watch.js
CHANGED
|
@@ -5,7 +5,11 @@ import { out, log, debug } from '../output.js';
|
|
|
5
5
|
const {
|
|
6
6
|
timeProfileAsync
|
|
7
7
|
} = await createTimeProfiler(showTimeProfiling);
|
|
8
|
+
|
|
9
|
+
// args: string[]
|
|
8
10
|
export async function watch() {
|
|
11
|
+
//const args = global.commandLineArguments
|
|
12
|
+
|
|
9
13
|
await out(chalk.brightblue`[${packageName}]...`);
|
|
10
14
|
const {
|
|
11
15
|
parseCommandLineArguments
|
|
@@ -14,6 +18,10 @@ export async function watch() {
|
|
|
14
18
|
'config': {
|
|
15
19
|
flag: 'c',
|
|
16
20
|
hasValue: true
|
|
21
|
+
},
|
|
22
|
+
'files': {
|
|
23
|
+
flag: 'f',
|
|
24
|
+
hasValue: true
|
|
17
25
|
}
|
|
18
26
|
};
|
|
19
27
|
const clArguments = await parseCommandLineArguments(allowedClArguments);
|
|
@@ -22,6 +30,12 @@ export async function watch() {
|
|
|
22
30
|
loadConfig
|
|
23
31
|
} = await import('./lib/loadConfig.js'); //// async function
|
|
24
32
|
const userConfig = 'config' in clArguments ? await loadConfig(clArguments.config) : await loadConfig();
|
|
33
|
+
if ('files' in clArguments) {
|
|
34
|
+
const files = clArguments.files;
|
|
35
|
+
if (!files) throw new Error('No pattern specified for --files or -f argument');
|
|
36
|
+
await console.log('Looking for tests using pattern: ' + files);
|
|
37
|
+
userConfig.tests = files;
|
|
38
|
+
}
|
|
25
39
|
const {
|
|
26
40
|
applyConfigDefaults
|
|
27
41
|
} = await import('./lib/applyConfigDefaults.js'); //// sync function
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sxy-test-runner",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/RobertSandiford/sxy-test-runner",
|
|
6
6
|
"repository": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"sxy-helpers": "^1.0.0",
|
|
45
45
|
"sxy-lib": "^1.0.12",
|
|
46
46
|
"sxy-lib-object-copy": "^1.0.5",
|
|
47
|
-
"sxy-loader": "^3.0.
|
|
47
|
+
"sxy-loader": "^3.0.35",
|
|
48
48
|
"sxy-standard": "^1.0.12",
|
|
49
49
|
"sxy-standard-object-copy": "^1.0.5"
|
|
50
50
|
},
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"unit-test-watch-files-and-run-tests": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/watchFilesAndRunTests.unitTest.js",
|
|
76
76
|
"unit-test-watch-files-and-run-tests-chokidar": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/watchFilesAndRunTestsChokidar.unitTest.js",
|
|
77
77
|
"unit-test-watch": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/watch.unitTest.js",
|
|
78
|
+
"unit-test-files": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/files.unitTest.js",
|
|
78
79
|
"unit-test-inject-properties": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/injectProperties.unitTest.js",
|
|
79
80
|
"unit-test-run-it": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/runIt.unitTest.js",
|
|
80
81
|
"unit-test-run-describe": "mocha --watch --parallel --config unitTesting/.mocharc.cjs --watch-files dist,unitTesting dist/**/runDescribe.unitTest.js",
|