Skip to content

regression-tests: update custom mocha reporter to exit rather than mocha itself

Administrator requested to merge wb/client-qa-mocha-reporter into main

Created by: burmudar

The custom mocha reporter didn't run for Sourcegraph QA tests aka client-regression tests. I dug into why and it comes down to:

  1. the regression tests get invoked with yarn run test:regression mocha --exit
  2. --exit means upon any test failure mocha will exit with a non-zero exit code
  3. Another reason to have it is incase a resource isn't properly closed, you don't have to worry since the whole process will exit
  4. --exit essentially invokes process.exit which leads to any files that are open to not be properly closed

Since process.exit doesn't allow any file to properly get closed, customMochaSpecReporter was not able to write all its contents to it's destination file.

test:regression current working directory

The regression test configuration assumes that is being invoked from the client/web directory, which means when mocha starts up, it doesn't see the .mochajs file in the root of the repository.

  • we now have the --config option on the test:regression mocha which points to the root .mochajs
  • the mochajs file assumed that is was always in the root of the repo, but since it is now being passed as an option for test:regression it has been updated to use absolute paths by determining the root of the directory
  • customMochaSpecReporter assumed that it was always being executed from the root of the directory but it now determines the root of the repo to ensure the annotation is always written to the root annotations directory

Test plan

  1. create the following sg.config.overwrite.yaml
tests:
  qa:
    cmd:
      ./dev/ci/integration/qa/test.sh ${SOURCEGRAPH_BASE_URL}
    env:
      TEST_USER_EMAIL: [email protected]
      TEST_USER_PASSWORD: supersecurepassword
      SOURCEGRAPH_BASE_URL: https://sourcegraph.test:3443
      SOURCEGRAPH_SUDO_USER: admin
      BROWSER: chrome
  1. sg start enterprise-e2e
  2. sg tests qa

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading