The current implementation of e2e tests contains cleanup code at the end of the tests. This is not ideal because if there is any exception thrown in a test, execution will stop, and the cleanup code never runs.
We should try to extract this code into a "finally" construct that always runs if we have anything to clean up. I believe (to be confirmed) tests within a Jest suite run sequentially. This means we could probably maintain a "test context" state on the test suite level that includes apps to be uninstalled and/or deleted after the test. A Jest afterEach block should then clean up whatever there is to clean up after each test and reset the test context.
The current implementation of e2e tests contains cleanup code at the end of the tests. This is not ideal because if there is any exception thrown in a test, execution will stop, and the cleanup code never runs.
We should try to extract this code into a "finally" construct that always runs if we have anything to clean up. I believe (to be confirmed) tests within a Jest suite run sequentially. This means we could probably maintain a "test context" state on the test suite level that includes apps to be uninstalled and/or deleted after the test. A Jest
afterEach
block should then clean up whatever there is to clean up after each test and reset the test context.https://github.com/toolsplus/nx-forge/blob/e4f0ad1fae40cb8355ee3b577556654a1b95e60f/e2e/forge-e2e/tests/register.executor.spec.ts#L69 https://github.com/toolsplus/nx-forge/blob/e4f0ad1fae40cb8355ee3b577556654a1b95e60f/e2e/forge-e2e/tests/deploy.executor.spec.ts#L68