Running tests overwrites test code from importer
Describe the bug The test reporter and test importer import code differently (the reporter doesn't seem to handle TypeScript code well, which I can create a separate ticket for if you like). This wouldn't be a problem except that the reporter overwrites the code which was previously (correctly) imported by the importer.
To Reproduce Steps to reproduce the behavior:
- Import a new Typescript test (I used
check-tests Mocha \"**/*{.,_}{test,spec,cy}.ts\" --typescript --sync --update-ids) - Observe that the test code is correctly imported:
- Run the test in question and report the results (I used
mocha --parallel --jobs 5 -R ./node_modules/@testomatio/reporter/lib/adapter/mocha.js). Note that TESTOMATIO_CREATE is not set, so I am not requesting that the test be imported in any way. - Observe that the test code has been replaced (this is now showing compiled output, not the original source code)
Expected behavior The test source code should not be modified when the test is executed. Or if it is, it should use the same method as used by the test importer so that it's at least consistent.
Additional Context
This seems to bypass the test versioning system. After the initial import, the test version is "V2", and the diff against LIVE looks like this:
After running the test, the source code changes as above but the test version is still "V2", but now the diff against LIVE looks like this:
The diff against "Current" is unchanged, and still looks like this:
@AZANIR we need to discuss this one
@AZANIR look through adapters, we take the code from the running function but we can add an option to remove it
For instance, this is mocha framework:
Please change introduce new env variable TESTOMATIO_UPDATE_CODE so it would be:
if (process.env.TESTOMATIO_UPDATE_CODE)) code = test.body.toString(),
@AZANIR up
https://github.com/testomatio/reporter/pull/436