Implement TeamCity test reporting integration by adding new scripts and documentation. Update package.json to include a new test command for TeamCity. Introduce TeamcityReporter class for formatting service messages and enhance test setup for compatibility with TeamCity environment.
This commit is contained in:
55
tests/setup.ts
Normal file
55
tests/setup.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { TeamcityReporter } from "./TeamcityReporter.ts";
|
||||
|
||||
// Check if running in TeamCity environment
|
||||
const isTeamCity = process.env.TEAMCITY_VERSION !== undefined;
|
||||
|
||||
// Override console methods to capture test output if needed
|
||||
if (isTeamCity) {
|
||||
// You can add global beforeAll/afterAll if needed
|
||||
console.log("TeamCity reporter enabled");
|
||||
}
|
||||
|
||||
// Export wrapper functions for test suites
|
||||
export function setupTeamCityReporting() {
|
||||
if (!isTeamCity) {
|
||||
return {
|
||||
reportSuiteStart: () => {},
|
||||
reportSuiteEnd: () => {},
|
||||
reportTestStart: () => {},
|
||||
reportTestEnd: () => {},
|
||||
reportTestFailed: () => {},
|
||||
reportTestError: () => {},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
reportSuiteStart: (name: string) => {
|
||||
TeamcityReporter.reportSuiteStart(name);
|
||||
},
|
||||
reportSuiteEnd: (name: string) => {
|
||||
TeamcityReporter.reportSuiteEnd(name);
|
||||
},
|
||||
reportTestStart: (name: string) => {
|
||||
TeamcityReporter.reportTestStart(name);
|
||||
},
|
||||
reportTestEnd: (name: string) => {
|
||||
TeamcityReporter.reportTestEnd(name);
|
||||
},
|
||||
reportTestFailed: (
|
||||
name: string,
|
||||
message: string,
|
||||
details: string,
|
||||
comparison?: { expected: string; actual: string }
|
||||
) => {
|
||||
TeamcityReporter.reportTestFailed(name, message, details, {
|
||||
comparisonFailure: !!comparison,
|
||||
expected: comparison?.expected || "",
|
||||
actual: comparison?.actual || "",
|
||||
});
|
||||
},
|
||||
reportTestError: (name: string, error: Error) => {
|
||||
TeamcityReporter.reportTestError(name, error);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user