ericclemmons/node-recorder

Throw if recorder writes to fixture twice

ericclemmons opened this issue · 2 comments

If a fixture is being recorded twice with different payloads, then that's a sign that there's a bug in the recorder or program:

  • Requesting /me with a cookie, but not setting username gets recorded as "all".
  • Requesting /me without a cookie, expecting a 403, but gets the previous user's data.

This is easily reproducible with current tests via Jest:

  1. jest --watch
  2. Toggle to RERECORD
  3. The tests re-run.

As a solution, I think that the JestRecorderWatchPlugin should revert back to REPLAY after re-recording.

const fetch = require("node-fetch");

describe("time", () => {
  it("should stand still", async () => {
    const res = await fetch("http://worldclockapi.com/api/json/pst/now");

    expect(await res.json()).toMatchInlineSnapshot();
  });
});