import fs from 'node:fs';
import path from 'node:path';
import test from '@ava/test';
import {cwd, fixture} from '../helpers/exec.js';
test('snapshot files are independent of test resolution order', async t => {
const options = {
cwd: cwd('intertest-order'),
env: {
AVA_FORCE_CI: 'not-ci',
},
};
const snapshotPath = path.join(options.cwd, 'test.js.snap');
t.teardown(() => {
fs.unlinkSync(snapshotPath);
fs.unlinkSync(path.join(options.cwd, 'test.js.md'));
});
await fixture(['test.js', '--update-snapshots'], options);
const snapshot = fs.readFileSync(snapshotPath);
await fixture(['test.js', '--update-snapshots'], {
...options,
env: {
INTERTEST_ORDER_REVERSE: 'true',
...options.env,
},
});
const snapshotReversed = fs.readFileSync(snapshotPath);
t.deepEqual(snapshot, snapshotReversed);
});