Skip to content

Using the after postprocessing function with nockBack #2495

Answered by mvelosop
mvelosop asked this question in Q&A
Discussion options

You must be logged in to vote

I just realized that I can achieve what I need in the before preprocessing function of the back options, by just modifying the response object in the definition.

Something like this:

  const prepareScope = (scope: Definition) => {
    (scope.response as any).expiresTimestamp = "1688046014999";
  };

  beforeAll(() => {
    const testDataFolder = path
      .basename(__filename)
      .replace(".spec.ts", ".test-data");

    nockBack.fixtures = path.join(__dirname, testDataFolder);
    nockBack.setMode("record");
  });

  beforeEach(async () => {
    ({ nockDone } = await nockBack(
      `${expect
        .getState()
        .currentTestName.split(" ")
        .join("-")}.test-data.json`,
…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mvelosop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant