Prior99 / jest-screenshot

A jest extension to deal with screenshots and all sorts of images.
MIT License
71 stars 21 forks source link

[Bug] Changing reportDir does not produce index.js or dist folder #17

Open tremorth opened 4 years ago

tremorth commented 4 years ago

I am using the configuration object, which can be used to change the path where the HTML report is generated.

So I am running it like this:

const jestScreenshot = require('jest-screenshot');
const {getTestScope} = require('../fakedata');

const {config, toMatchImageSnapshot} = jestScreenshot;

jestScreenshot.setupJestScreenshot();

expect.extend({
    screenshotMatcher(received, threshold) {
        const configuration = config();

        configuration.snapshotsDir = '../__snapshots__/';

        configuration.reportDir = `screenshot-report-${getTestScope()}`;

        if (threshold) {
            configuration.pixelThresholdAbsolute = threshold;
            configuration.pixelThresholdRelative = null;
        } else {
            configuration.pixelThresholdRelative = 0;
            configuration.pixelThresholdAbsolute = 0;
        }

        return toMatchImageSnapshot.call(this, received, configuration);
    }
});

To reproduce the bug

What the report folder should have:

image

  1. Change configuration.reportDir = 'some_dir'

  2. Run tests that has failing image

On image-diff failure, index.js or dist-folder are not created under 'some_dir'. No HTML report is available.

What the report folder has:

image

Prior99 commented 4 years ago

My guess would be, that you also need to configure this for the reporter in the configuration file.