Skip to content

Commit f141648

Browse files
authored
Fix deprecated jest junit instructions (circleci#2557)
* rewrite deprecated jest instructions * update bracing and indentation in karma.conf.js * fix typo * remove extraneous information
1 parent b18a8b2 commit f141648

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

jekyll/_cci2/collect-test-data.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -318,29 +318,40 @@ A working `.circleci/config.yml` section might look like this:
318318
// karma.conf.js
319319
320320
// additional config...
321-
322-
reporters: ['junit'],
323-
324-
junitReporter: {
325-
outputDir: process.env.JUNIT_REPORT_PATH,
326-
outputFile: process.env.JUNIT_REPORT_NAME,
327-
useBrowserName: false
328-
},
321+
{
322+
reporters: ['junit'],
323+
junitReporter: {
324+
outputDir: process.env.JUNIT_REPORT_PATH,
325+
outputFile: process.env.JUNIT_REPORT_NAME,
326+
useBrowserName: false
327+
},
328+
}
329329
// additional config...
330330
```
331331

332332
#### Jest
333333

334-
To collect Jest data, add a JUnit coverage reporter by running:
334+
To collect Jest data,
335+
first create a Jest config file called `jest.config.js` with the following:
335336

336-
yarn add --dev jest-junit
337+
```javascript
338+
// jest.config.js
339+
{
340+
reporters: ["default", "jest-junit"],
341+
}
342+
```
337343

338-
In your configuration, form a command to output using the reporter:
344+
In your `.circleci/config.yml`,
345+
add the following `run` steps:
339346

340347
```yaml
341-
- run:
342-
name: Jest Suite
343-
command: yarn jest tests --ci --testResultsProcessor="jest-junit"
348+
steps:
349+
- run:
350+
name: Install JUnit coverage reporter
351+
run: yarn add --dev jest-junit
352+
- run:
353+
name: Run tests with JUnit as reporter
354+
command: jest --ci --reporters=default --reporters=jest-junit
344355
environment:
345356
JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml"
346357
```

0 commit comments

Comments
 (0)