diff --git a/packages/jest/README.md b/packages/jest/README.md index 2ebc28c7..86a6a182 100644 --- a/packages/jest/README.md +++ b/packages/jest/README.md @@ -41,13 +41,15 @@ or set the `--reporters` option when running the `jest` npx jest --reporters=@currents/jest ``` -The reporter saves the test results in a folder named using the pattern `.currents/[timestamp]-[uuidv4()]` in the root directory. We recomment to add `.currents*` to your `.gitignore` file. +The reporter saves the test results in a folder named using the pattern `.currents/[timestamp]-[uuidv4()]` in the root directory. You can override this with the `reportDir` option or the `CURRENTS_REPORT_DIR` environment variable (env takes precedence). We recommend adding `.currents*` to your `.gitignore` file. ## Configuration -| Property | Type | Description | Environment variable | Default | -| ----------- | -------- | ---------------------- | --------------------- | -------------------------------- | -| `reportDir` | `string` | Test results directory | `CURRENTS_REPORT_DIR` | `.currents/[timestamp]-[uuidv4]` | +| Property | Type | Description | Environment variable | Default | +| ----------- | -------- | ---------------------- | --------------------- | ---------------------------------- | +| `reportDir` | `string` | Test results directory | `CURRENTS_REPORT_DIR` | `.currents/[timestamp]-[uuidv4()]` | + +`CURRENTS_REPORT_DIR` overrides `reportDir` when both are set. ## Troubleshooting diff --git a/packages/jest/src/reporter.ts b/packages/jest/src/reporter.ts index 0ff9fe7d..57fc87d4 100644 --- a/packages/jest/src/reporter.ts +++ b/packages/jest/src/reporter.ts @@ -88,8 +88,10 @@ export default class CustomReporter implements Reporter { this.specsCount = aggregatedResults.numTotalTestSuites; - this.reportDir = this.options?.reportDir - ? await createFolder(this.options.reportDir) + const envReportDir = process.env.CURRENTS_REPORT_DIR?.trim(); + const reportDirOption = envReportDir || this.options?.reportDir; + this.reportDir = reportDirOption + ? await createFolder(reportDirOption) : await createUniqueFolder(this.rootDir, '.currents'); info('[currents]: Run started'); diff --git a/turbo.json b/turbo.json index a575a319..9d2d6bc0 100644 --- a/turbo.json +++ b/turbo.json @@ -15,6 +15,7 @@ "CURRENTS_REST_API_URL", "CURRENTS_REMOTE_LOGGING", "CURRENTS_PREVIOUS_CI_BUILD_ID", + "CURRENTS_REPORT_DIR", "TF_BUILD", "TF_BUILD_BUILDNUMBER", "AZURE_HTTP_USER_AGENT",