@wp-tester/phpunit 0.1.0 → 0.1.2
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/runner.d.ts +1 -14
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +94 -143
- package/dist/runner.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/wordpress-test-lib.js +1 -1
- package/package.json +4 -4
- package/dist/junit-parser.d.ts +0 -11
- package/dist/junit-parser.d.ts.map +0 -1
- package/dist/junit-parser.js +0 -114
- package/dist/junit-parser.js.map +0 -1
|
@@ -248,7 +248,7 @@ $table_prefix = 'wptests_';
|
|
|
248
248
|
// Use a generic domain that tests can override via update_option('home')
|
|
249
249
|
// Don't use Playground's actual domain here as it prevents tests from
|
|
250
250
|
// dynamically changing the home URL for mock HTTP requests
|
|
251
|
-
define( 'WP_TESTS_DOMAIN', 'example.org' );
|
|
251
|
+
// define( 'WP_TESTS_DOMAIN', 'example.org' ); # The domain is defined after Playground starts to correctly set the port
|
|
252
252
|
define( 'WP_TESTS_EMAIL', 'admin@example.org' );
|
|
253
253
|
define( 'WP_TESTS_TITLE', 'Test Blog' );
|
|
254
254
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-tester/phpunit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "PHPUnit test runner for WordPress projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"type-check": "tsc --noEmit"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@wp-tester/config": "^0.1.
|
|
31
|
-
"@wp-tester/results": "^0.1.
|
|
32
|
-
"@wp-tester/runtime": "^0.1.
|
|
30
|
+
"@wp-tester/config": "^0.1.2",
|
|
31
|
+
"@wp-tester/results": "^0.1.2",
|
|
32
|
+
"@wp-tester/runtime": "^0.1.2",
|
|
33
33
|
"xml2js": "^0.6.2",
|
|
34
34
|
"yauzl": "*"
|
|
35
35
|
},
|
package/dist/junit-parser.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Report } from "@wp-tester/results";
|
|
2
|
-
/**
|
|
3
|
-
* Parse JUnit XML output to CTRF format
|
|
4
|
-
* PHPUnit outputs test results in JUnit XML format
|
|
5
|
-
*
|
|
6
|
-
* @param xmlOutput - JUnit XML output string
|
|
7
|
-
* @param environmentName - Name of the test environment
|
|
8
|
-
* @returns CTRF Report
|
|
9
|
-
*/
|
|
10
|
-
export declare function parseJUnitXml(xmlOutput: string, environmentName?: string): Promise<Report>;
|
|
11
|
-
//# sourceMappingURL=junit-parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"junit-parser.d.ts","sourceRoot":"","sources":["../src/junit-parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,MAAM,EAAmB,MAAM,oBAAoB,CAAC;AA4ChF;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAwHjB"}
|
package/dist/junit-parser.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { parseStringPromise } from "xml2js";
|
|
2
|
-
import { EMPTY_REPORT } from "@wp-tester/results";
|
|
3
|
-
/**
|
|
4
|
-
* Parse JUnit XML output to CTRF format
|
|
5
|
-
* PHPUnit outputs test results in JUnit XML format
|
|
6
|
-
*
|
|
7
|
-
* @param xmlOutput - JUnit XML output string
|
|
8
|
-
* @param environmentName - Name of the test environment
|
|
9
|
-
* @returns CTRF Report
|
|
10
|
-
*/
|
|
11
|
-
export async function parseJUnitXml(xmlOutput, environmentName) {
|
|
12
|
-
const startTime = Date.now();
|
|
13
|
-
try {
|
|
14
|
-
const parsed = (await parseStringPromise(xmlOutput));
|
|
15
|
-
// Handle both single testsuite and testsuites wrapper
|
|
16
|
-
const testsuites = parsed.testsuites?.testsuite ||
|
|
17
|
-
(parsed.testsuite ? [parsed.testsuite] : []);
|
|
18
|
-
if (testsuites.length === 0) {
|
|
19
|
-
return EMPTY_REPORT;
|
|
20
|
-
}
|
|
21
|
-
// Collect all tests from all test suites (recursively)
|
|
22
|
-
const tests = [];
|
|
23
|
-
// Recursive function to extract testcases from nested testsuites
|
|
24
|
-
function collectTestCases(suite) {
|
|
25
|
-
// Process testcases in this suite
|
|
26
|
-
const testcases = suite.testcase || [];
|
|
27
|
-
for (const testcase of testcases) {
|
|
28
|
-
const attrs = testcase.$ || {};
|
|
29
|
-
const testName = attrs.name || "Unknown test";
|
|
30
|
-
const className = attrs.class || attrs.classname || "";
|
|
31
|
-
const fullName = className ? `${className}::${testName}` : testName;
|
|
32
|
-
const duration = attrs.time ? parseFloat(attrs.time) * 1000 : 0; // Convert to ms
|
|
33
|
-
let status = "passed";
|
|
34
|
-
let message;
|
|
35
|
-
let trace;
|
|
36
|
-
// Check for failure
|
|
37
|
-
if (testcase.failure && testcase.failure.length > 0) {
|
|
38
|
-
status = "failed";
|
|
39
|
-
const failure = testcase.failure[0];
|
|
40
|
-
message = failure.$?.message || failure.$?.type || "Test failed";
|
|
41
|
-
trace = failure._ || "";
|
|
42
|
-
}
|
|
43
|
-
// Check for error
|
|
44
|
-
else if (testcase.error && testcase.error.length > 0) {
|
|
45
|
-
status = "failed";
|
|
46
|
-
const error = testcase.error[0];
|
|
47
|
-
message = error.$?.message || error.$?.type || "Test error";
|
|
48
|
-
trace = error._ || "";
|
|
49
|
-
}
|
|
50
|
-
// Check for skipped
|
|
51
|
-
else if (testcase.skipped && testcase.skipped.length > 0) {
|
|
52
|
-
status = "skipped";
|
|
53
|
-
const skipped = testcase.skipped[0];
|
|
54
|
-
message = skipped.$?.message || "Test skipped";
|
|
55
|
-
}
|
|
56
|
-
tests.push({
|
|
57
|
-
name: fullName,
|
|
58
|
-
status,
|
|
59
|
-
duration,
|
|
60
|
-
...(message && { message }),
|
|
61
|
-
...(trace && { trace }),
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
// Recursively process nested testsuites
|
|
65
|
-
const nestedSuites = suite.testsuite || [];
|
|
66
|
-
for (const nestedSuite of nestedSuites) {
|
|
67
|
-
collectTestCases(nestedSuite);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Collect test cases from all top-level testsuites
|
|
71
|
-
for (const suite of testsuites) {
|
|
72
|
-
collectTestCases(suite);
|
|
73
|
-
}
|
|
74
|
-
// Calculate summary
|
|
75
|
-
const stopTime = Date.now();
|
|
76
|
-
const passed = tests.filter((t) => t.status === "passed").length;
|
|
77
|
-
const failed = tests.filter((t) => t.status === "failed").length;
|
|
78
|
-
const skipped = tests.filter((t) => t.status === "skipped").length;
|
|
79
|
-
const pending = tests.filter((t) => t.status === "pending").length;
|
|
80
|
-
const toolName = environmentName
|
|
81
|
-
? `wp-tester-phpunit (${environmentName})`
|
|
82
|
-
: "wp-tester-phpunit";
|
|
83
|
-
return {
|
|
84
|
-
...EMPTY_REPORT,
|
|
85
|
-
results: {
|
|
86
|
-
summary: {
|
|
87
|
-
tests: tests.length,
|
|
88
|
-
passed,
|
|
89
|
-
failed,
|
|
90
|
-
skipped,
|
|
91
|
-
pending,
|
|
92
|
-
other: 0,
|
|
93
|
-
start: startTime,
|
|
94
|
-
stop: stopTime,
|
|
95
|
-
},
|
|
96
|
-
tool: {
|
|
97
|
-
name: toolName,
|
|
98
|
-
},
|
|
99
|
-
tests: tests.map((test) => ({
|
|
100
|
-
name: test.name,
|
|
101
|
-
status: test.status,
|
|
102
|
-
duration: test.duration,
|
|
103
|
-
...(test.message && { message: test.message }),
|
|
104
|
-
...(test.trace && { trace: test.trace }),
|
|
105
|
-
})),
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
console.error("Error parsing JUnit XML:", error);
|
|
111
|
-
return EMPTY_REPORT;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=junit-parser.js.map
|
package/dist/junit-parser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"junit-parser.js","sourceRoot":"","sources":["../src/junit-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAgC,MAAM,oBAAoB,CAAC;AA4ChF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,SAAiB,EACjB,eAAwB;IAExB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,CAAC,MAAM,kBAAkB,CAAC,SAAS,CAAC,CAAa,CAAC;QAEjE,sDAAsD;QACtD,MAAM,UAAU,GAAqB,MAAM,CAAC,UAAU,EAAE,SAAS;YAC/D,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAE/C,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,uDAAuD;QACvD,MAAM,KAAK,GAMN,EAAE,CAAC;QAER,iEAAiE;QACjE,SAAS,gBAAgB,CAAC,KAAqB;YAC7C,kCAAkC;YAClC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;YACvC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;gBAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,IAAI,cAAc,CAAC;gBAC9C,MAAM,SAAS,GA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