Use mocha directly for integration tests and move to shared/
Created by: felixfbecker
This implements the idea of using Mocha directly for integration tests instead of reimplementing the describe
/test
/it
/... APIs. Reasons:
- Adds complexity in the implementation
- Certain things don't work unless they are also reimplemented, e.g.
it.only()
/it.skip()
- Implementation code was hard to follow
- Mocha's
beforeEach()
etc cannot be used anymore - everything must be setup (i.e. potentially duplicated) within the test- This also means if the setup were to always fail, every test would still be run, instead of Mocha aborting after the
before
failed
- This also means if the setup were to always fail, every test would still be run, instead of Mocha aborting after the
- Hazards of using the parent scope's
test
function if parameter was not destructured in inner scope - Difficult to customize behavior for browser vs web and have code reside in the respective project folders, because entire Mocha API needs to be wrapped again
Instead, a "test context" is created in beforeEach()
with a factory function and assigned to a variable. That factory function lives in shared/ and can be extended in web/ and browser/ respectively.
As part of this serves assets directly in an interceptor instead of using an Express server on localhost. This means we no longer have different URLs in record replay modes, which would have been an issue with the browser extension, because it only works as long as we ignore the host and only have one host (but in the browser extension, we need to also mock other hosts, e.g. github.com).
All integration test infra is moved to shared/, while the actual web app test suite lives in web/. The JSContext and index.html logic also lives in web/.