regression-tests: update custom mocha reporter to exit rather than mocha itself
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:
- the regression tests get invoked with
yarn run test:regression mocha --exit
-
--exit
means upon any test failure mocha will exit with a non-zero exit code - 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
-
--exit
essentially invokesprocess.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 thetest: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
- 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
sg start enterprise-e2e
sg tests qa
App preview:
Check out the client app preview documentation to learn more.