jest-playback icon indicating copy to clipboard operation
jest-playback copied to clipboard

Working with `axios-cookiejar-support` ?

Open skilbjo opened this issue 5 months ago • 1 comments

I'm not able to get this working to 1) record requests and 2) play them back.

the test works perfectly fine if i comment out the await jestPlayback.setup({ ... }) line.

src.ts

import axios from 'axios'
import { wrapper } from 'axios-cookiejar-support';

wrapper(axios);

const data = (await axios.request({
  ...
})).data

test.ts

import * as jestPlayback from 'jest-playback';
await jestPlayback.setup({ mode: jestPlayback.Mode.Auto });

import * as src from './src'

// do tests

when i run the test in jest,

node --experimental-vm-modules node_modules/.bin/jest test.ts

 FAIL  test.test.ts
  test
    ✕  happy path (1364 ms)

  ● test ›  happy path

    AxiosError: Request failed with status code 401

      at settle (node_modules/axios/lib/core/settle.js:19:12)
      at PassThrough.handleStreamEnd (node_modules/axios/lib/adapters/http.js:589:11)

test.ts.snap

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`test happy path: (jest-playback) 86230859c6 1`] = `
NONE/11 401 Unauthorized
cf-cache-status: DYNAMIC
cf-ray: 8492d7c0ac274211-EWR
connection: keep-alive
content-type: text/html; charset=UTF-8
date: Sun, 21 Jan 2024 22:02:40 GMT
server: cloudflare
set-cookie: _cfuvid=2q37XoAAhzrdz.kcRy9F4Jjf6lAhpOxuqI92YqyvaMU-1705874560244-0-604800000; path=/; domain=.bamboohr.com; HttpOnly; Secure; SameSite=None
strict-transport-security: max-age=31536000; includeSubDomains; preload
transfer-encoding: chunked
x-frame-options: SAMEORIGIN
x-session-invalid: true
`;

skilbjo avatar Jan 21 '24 22:01 skilbjo