sxy-test-runner 1.4.3 → 1.4.5
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/index.js +0 -2
- package/dist/cli/lib/applyConfigDefaults.js +1 -1
- package/dist/cli/lib/buildDependencyTree.js +0 -1
- package/dist/cli/lib/loadTestFile.unitTest.js +30 -30
- package/dist/cli/lib/loadTestFileStatic.js +39 -39
- package/dist/cli/lib/loadTestFileStatic.unitTest.js +28 -28
- package/dist/cli/lib/parseDescribe.js +8 -2
- package/dist/cli/lib/runDescribe.js +20 -2
- package/dist/cli/lib/runDescribe.old.unitTest.js +439 -439
- package/dist/cli/lib/runTest-old.js +158 -158
- package/dist/cli/lib/runTest-old.unitTest.js +182 -182
- package/dist/cli/lib/runTests.js +9 -6
- package/dist/cli/lib/showTestLoadingError.js +1 -1
- package/dist/cli/lib/showTestResult.js +13 -1
- package/dist/cli/lib/watchFilesAndRunTests.unitTest.js +1 -1
- package/dist/cli/lib/watchFilesAndRunTestsChokidar.unitTest.js +1 -1
- package/dist/cli/lib/watchFilesAndRunTestsNodeWatch.unitTest.js +1 -1
- package/dist/cli/once.unitTest.js +38 -38
- package/dist/describe-old.js +183 -183
- package/package.json +6 -3
- package/dist/cli/lib/esmReload.unitTest.js +0 -8
- package/dist/cli/lib/load.js +0 -3
- package/dist/cli/lib/load.unitTest copy.js +0 -7
- package/dist/cli/lib/load.unitTest.js +0 -7
- package/dist/index.d.ts +0 -7
- package/dist/load.js +0 -3
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeStructuredConfig, createTimeProfiler } from 'sxy-dev-tools';
|
|
2
|
-
import objectCopy from 'sxy-lib-object-copy';
|
|
2
|
+
import { objectCopy } from 'sxy-lib-object-copy';
|
|
3
3
|
import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js';
|
|
4
4
|
//import chalk from 'chalk-extensions'
|
|
5
5
|
//import { out, log, debug } from '../../output.js'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import dependencyTree from 'dependency-tree';
|
|
2
2
|
import { out, log, debug } from '../../output.js';
|
|
3
3
|
import slash from 'slash';
|
|
4
|
-
import 'sxy-standard/light.js';
|
|
5
4
|
export async function buildDependencyTree(config, filename) {
|
|
6
5
|
filename = await slash(filename); // convert to forward slashes
|
|
7
6
|
|
|
@@ -4,36 +4,36 @@ import { defaultConfig } from './defaultConfig.js';
|
|
|
4
4
|
// loadTestFile(config, testFile) ???
|
|
5
5
|
|
|
6
6
|
await mochaDescribe('loadTestFile() function', async function () {
|
|
7
|
-
/*
|
|
8
|
-
mochaIt('should load a test file, retreiving describes', function() {
|
|
9
|
-
|
|
10
|
-
const config = defaultConfig
|
|
11
|
-
|
|
12
|
-
const sampleTestFile = 'unitTesting/sampleTests/1.test.js'
|
|
13
|
-
|
|
14
|
-
const test = loadTestFile(config, sampleTestFile)
|
|
15
|
-
|
|
16
|
-
test.describes.length.should.equal(1)
|
|
17
|
-
test.describes.at(-1).counter.should.equal(1)
|
|
18
|
-
test.describes[0].tests.should.be.a('function')
|
|
19
|
-
//test.describes.at(-1).its.at(-1).counter.should.equal(1)
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
mochaIt('should correctly load a second test file', function() {
|
|
24
|
-
|
|
25
|
-
const config = defaultConfig
|
|
26
|
-
|
|
27
|
-
const sampleTestFile = 'unitTesting/sampleTests/2.test.js'
|
|
28
|
-
|
|
29
|
-
const test = loadTestFile(config, sampleTestFile)
|
|
30
|
-
|
|
31
|
-
test.describes.length.should.equal(1)
|
|
32
|
-
test.describes.at(-1).counter.should.equal(1)
|
|
33
|
-
test.describes[0].tests.should.be.a('function')
|
|
34
|
-
//test.describes.at(-1).its.at(-1).counter.should.equal(2)
|
|
35
|
-
|
|
36
|
-
})
|
|
7
|
+
/*
|
|
8
|
+
mochaIt('should load a test file, retreiving describes', function() {
|
|
9
|
+
|
|
10
|
+
const config = defaultConfig
|
|
11
|
+
|
|
12
|
+
const sampleTestFile = 'unitTesting/sampleTests/1.test.js'
|
|
13
|
+
|
|
14
|
+
const test = loadTestFile(config, sampleTestFile)
|
|
15
|
+
|
|
16
|
+
test.describes.length.should.equal(1)
|
|
17
|
+
test.describes.at(-1).counter.should.equal(1)
|
|
18
|
+
test.describes[0].tests.should.be.a('function')
|
|
19
|
+
//test.describes.at(-1).its.at(-1).counter.should.equal(1)
|
|
20
|
+
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
mochaIt('should correctly load a second test file', function() {
|
|
24
|
+
|
|
25
|
+
const config = defaultConfig
|
|
26
|
+
|
|
27
|
+
const sampleTestFile = 'unitTesting/sampleTests/2.test.js'
|
|
28
|
+
|
|
29
|
+
const test = loadTestFile(config, sampleTestFile)
|
|
30
|
+
|
|
31
|
+
test.describes.length.should.equal(1)
|
|
32
|
+
test.describes.at(-1).counter.should.equal(1)
|
|
33
|
+
test.describes[0].tests.should.be.a('function')
|
|
34
|
+
//test.describes.at(-1).its.at(-1).counter.should.equal(2)
|
|
35
|
+
|
|
36
|
+
})
|
|
37
37
|
*/
|
|
38
38
|
await mochaIt('should correctly load a file with describes without any its/tests', async function () {
|
|
39
39
|
const config = defaultConfig;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
|
|
2
|
-
/*
|
|
3
|
-
|
|
4
|
-
I can't remember what this was for.
|
|
5
|
-
|
|
6
|
-
Would need updating to the new file load system if used
|
|
7
|
-
|
|
8
|
-
import { createTimeProfiler } from 'sxy-dev-tools'
|
|
9
|
-
import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js'
|
|
10
|
-
import { join } from 'path'
|
|
11
|
-
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling)
|
|
12
|
-
|
|
13
|
-
// could be used within runTests
|
|
14
|
-
// think its not used now
|
|
15
|
-
|
|
16
|
-
export function loadTestFileStatic(config, testFile) {
|
|
17
|
-
|
|
18
|
-
return timeProfileAsync(`load test ${testFile} statically (standard import)`, () => {
|
|
19
|
-
|
|
20
|
-
//console.log('loadTestFileStatic', config, testFile)
|
|
21
|
-
|
|
22
|
-
const projectDir = process.cwd()
|
|
23
|
-
|
|
24
|
-
global.testState = {
|
|
25
|
-
describes: [],
|
|
26
|
-
describeCounter: 1
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
import( 'file://' + join(projectDir, testFile) )
|
|
30
|
-
|
|
31
|
-
const test = {
|
|
32
|
-
file: testFile,
|
|
33
|
-
describes: global.testState.describes
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return test
|
|
37
|
-
|
|
38
|
-
} )
|
|
39
|
-
|
|
40
|
-
}
|
|
2
|
+
/*
|
|
3
|
+
|
|
4
|
+
I can't remember what this was for.
|
|
5
|
+
|
|
6
|
+
Would need updating to the new file load system if used
|
|
7
|
+
|
|
8
|
+
import { createTimeProfiler } from 'sxy-dev-tools'
|
|
9
|
+
import { packageName, cliName, configFileName, configLocations, showTimeProfiling } from '../../config.js'
|
|
10
|
+
import { join } from 'path'
|
|
11
|
+
const { timeProfileAsync } = createTimeProfiler(showTimeProfiling)
|
|
12
|
+
|
|
13
|
+
// could be used within runTests
|
|
14
|
+
// think its not used now
|
|
15
|
+
|
|
16
|
+
export function loadTestFileStatic(config, testFile) {
|
|
17
|
+
|
|
18
|
+
return timeProfileAsync(`load test ${testFile} statically (standard import)`, () => {
|
|
19
|
+
|
|
20
|
+
//console.log('loadTestFileStatic', config, testFile)
|
|
21
|
+
|
|
22
|
+
const projectDir = process.cwd()
|
|
23
|
+
|
|
24
|
+
global.testState = {
|
|
25
|
+
describes: [],
|
|
26
|
+
describeCounter: 1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
import( 'file://' + join(projectDir, testFile) )
|
|
30
|
+
|
|
31
|
+
const test = {
|
|
32
|
+
file: testFile,
|
|
33
|
+
describes: global.testState.describes
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return test
|
|
37
|
+
|
|
38
|
+
} )
|
|
39
|
+
|
|
40
|
+
}
|
|
41
41
|
*/
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
|
|
2
|
-
/*
|
|
3
|
-
import { loadTestFileStatic } from "./loadTestFileStatic.js"
|
|
4
|
-
import { applyConfigDefaults } from './applyConfigDefaults.js'
|
|
5
|
-
|
|
6
|
-
// loadTestFile(config, testFile) ???
|
|
7
|
-
|
|
8
|
-
mochaDescribe('loadTestFileStatic() function', function() {
|
|
9
|
-
|
|
10
|
-
mochaIt('should load a test file, retreiving describes', function() {
|
|
11
|
-
|
|
12
|
-
const config = applyConfigDefaults({})
|
|
13
|
-
|
|
14
|
-
const sampleTestFile = 'unitTesting/sampleTests/1.test.js'
|
|
15
|
-
|
|
16
|
-
const test = loadTestFileStatic(config, sampleTestFile)
|
|
17
|
-
|
|
18
|
-
test.describes.length.should.equal(1)
|
|
19
|
-
test.describes[0].counter.should.equal(1)
|
|
20
|
-
test.describes[0].its[0].counter.should.equal(1)
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// mochaIt('should be able to load a test file again, after cache is cleard', function() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// })
|
|
28
|
-
|
|
29
|
-
})
|
|
2
|
+
/*
|
|
3
|
+
import { loadTestFileStatic } from "./loadTestFileStatic.js"
|
|
4
|
+
import { applyConfigDefaults } from './applyConfigDefaults.js'
|
|
5
|
+
|
|
6
|
+
// loadTestFile(config, testFile) ???
|
|
7
|
+
|
|
8
|
+
mochaDescribe('loadTestFileStatic() function', function() {
|
|
9
|
+
|
|
10
|
+
mochaIt('should load a test file, retreiving describes', function() {
|
|
11
|
+
|
|
12
|
+
const config = applyConfigDefaults({})
|
|
13
|
+
|
|
14
|
+
const sampleTestFile = 'unitTesting/sampleTests/1.test.js'
|
|
15
|
+
|
|
16
|
+
const test = loadTestFileStatic(config, sampleTestFile)
|
|
17
|
+
|
|
18
|
+
test.describes.length.should.equal(1)
|
|
19
|
+
test.describes[0].counter.should.equal(1)
|
|
20
|
+
test.describes[0].its[0].counter.should.equal(1)
|
|
21
|
+
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// mochaIt('should be able to load a test file again, after cache is cleard', function() {
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// })
|
|
28
|
+
|
|
29
|
+
})
|
|
30
30
|
*/
|
|
@@ -58,13 +58,19 @@ export async function parseDescribe(config, describe) {
|
|
|
58
58
|
afterEachTest
|
|
59
59
|
};
|
|
60
60
|
await addExports(describeParcel, beforeDescribeExports);
|
|
61
|
-
|
|
61
|
+
let error;
|
|
62
|
+
try {
|
|
63
|
+
await describe.tests(describeParcel);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
error = e;
|
|
66
|
+
}
|
|
62
67
|
return {
|
|
63
68
|
its,
|
|
64
69
|
beforeDescribeExports,
|
|
65
70
|
afterDescribeFunc,
|
|
66
71
|
beforeEachTestFunc,
|
|
67
|
-
afterEachTestFunc
|
|
72
|
+
afterEachTestFunc,
|
|
73
|
+
error
|
|
68
74
|
};
|
|
69
75
|
});
|
|
70
76
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { timeProfileAsync } from './timeProfier.js';
|
|
2
2
|
import { parseDescribe } from './parseDescribe.js';
|
|
3
3
|
import { runDescribeRun } from './runDescribeRun.js';
|
|
4
|
+
async function createDescribeErrorResult(describe, error) {
|
|
5
|
+
return {
|
|
6
|
+
counter: describe.counter,
|
|
7
|
+
thing: describe.thing,
|
|
8
|
+
success: false,
|
|
9
|
+
itResults: [],
|
|
10
|
+
itResultsSummary: {
|
|
11
|
+
total: 0,
|
|
12
|
+
passes: 0
|
|
13
|
+
},
|
|
14
|
+
error
|
|
15
|
+
};
|
|
16
|
+
}
|
|
4
17
|
export async function runDescribe(config, describe) {
|
|
5
18
|
return await timeProfileAsync(`run describe ${describe.thing}`, async () => {
|
|
6
19
|
const capturingConsoleLog = config.execution.describes === 'sequential';
|
|
@@ -14,8 +27,13 @@ export async function runDescribe(config, describe) {
|
|
|
14
27
|
}
|
|
15
28
|
////
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
|
|
30
|
+
let describeResult;
|
|
31
|
+
try {
|
|
32
|
+
const parsedDescribe = await parseDescribe(config, describe);
|
|
33
|
+
describeResult = parsedDescribe.error ? await createDescribeErrorResult(describe, parsedDescribe.error) : await runDescribeRun(config, describe, parsedDescribe);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
describeResult = await createDescribeErrorResult(describe, e);
|
|
36
|
+
}
|
|
19
37
|
describeResult.logs = logs;
|
|
20
38
|
if (capturingConsoleLog) {
|
|
21
39
|
console.log = previousConsoleLog; // eslint-disable-line no-console
|