app icon indicating copy to clipboard operation
app copied to clipboard

Running tests overwrites test code from importer

Open cjol opened this issue 1 year ago • 2 comments

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:

  1. Import a new Typescript test (I used check-tests Mocha \"**/*{.,_}{test,spec,cy}.ts\" --typescript --sync --update-ids)
  2. Observe that the test code is correctly imported:
    image
  3. 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.
  4. Observe that the test code has been replaced (this is now showing compiled output, not the original source code) image

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: image 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: image

The diff against "Current" is unchanged, and still looks like this: image

cjol avatar Jun 24 '24 08:06 cjol

@AZANIR we need to discuss this one

DavertMik avatar Aug 05 '24 17:08 DavertMik

@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:

Image

Please change introduce new env variable TESTOMATIO_UPDATE_CODE so it would be:

if (process.env.TESTOMATIO_UPDATE_CODE)) code = test.body.toString(),

DavertMik avatar Aug 21 '24 22:08 DavertMik

@AZANIR up

DavertMik avatar Nov 11 '24 11:11 DavertMik

https://github.com/testomatio/reporter/pull/436

olexandr13 avatar Nov 12 '24 15:11 olexandr13