dwjohnston / msw-webarchive-issue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repro for this issue here: Tapico/tapico-msw-webarchive#16

Instructions

Start server with node server/server.js

Start app with yarn start

Observe behaviour.

Run tests with yarn test

Observe that tests fail

Change this line in App.tsx

async function getData() {
-  const result = await fetch("/hello");  
+  const result = await fetch("http://localhost:3000/hello");  
    const json = await result.json(); 

  return json; 
}

Observe that this fixes the issue. However, it's not ideal

Alternative workaround

Revert previous change, and add this to your test:

traffic.log.entries.forEach((v) => {
  v.request.url = v.request.url.replace('http://localhost:3000/', 'http://localhost/');
})

About

License:MIT License


Languages

Language:TypeScript 47.1%Language:HTML 31.5%Language:JavaScript 11.1%Language:CSS 10.3%