Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure that Jest Integration tests are producing JUnit correctly #104935

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion jest.config.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

const preset = require('@kbn/test/jest-preset');
const { REPO_ROOT } = require('@kbn/dev-utils');

module.exports = {
preset: '@kbn/test',
Expand All @@ -21,7 +22,13 @@ module.exports = {
],
reporters: [
'default',
['@kbn/test/target_node/jest/junit_reporter', { reportName: 'Jest Integration Tests' }],
[
'@kbn/test/target_node/jest/junit_reporter',
{
reportName: 'Jest Integration Tests',
rootDirectory: REPO_ROOT,
},
],
],
coverageReporters: !!process.env.CI
? [['json', { file: 'jest-integration.json' }]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ it('builds expected bundles, saves bundle counts to metadata', async () => {
assert('produce one worker started event', workerStarted.length === 1);

const runningStates = msgs.filter((msg) => msg.state.phase === 'running');
assert(
'produce three to five "running" states',
runningStates.length >= 3 && runningStates.length <= 5
);
assert('produce three to five "running" states', runningStates.length > 10);

const bundleNotCachedEvents = msgs.filter((msg) => msg.event?.type === 'bundle not cached');
assert('produce three "bundle not cached" events', bundleNotCachedEvents.length === 3);
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-test/src/jest/junit_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export default class JestJUnitReporter extends BaseReporter {

const reportPath = getUniqueJunitReportPath(rootDirectory, reportName);
const reportXML = root.end();

process.stdout.write(`\nWriting Jest JUnit report to [${reportPath}]\n\n`);

mkdirSync(dirname(reportPath), { recursive: true });
writeFileSync(reportPath, reportXML, 'utf8');
}
Expand Down