angrykoala / angrykoala/wendigo

CORS mock not resolving

Abierto
#464 2 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
JavaScript
Estrellas
151
Forks
21
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I tried to mock a CORS request and it didn't work.\
The mock appears as called but the `fetch` in the web code is not resolving.

Here is a piece of code that reproduces the issue:

```js
const Wendigo = require('wendigo');

const MAIN_ORIGIN = 'http://example.com'
const MAIN_URL = `${MAIN_ORIGIN}/hello`;
const FETCH_URL = 'http://otherexample.com/eehehhehe';

let browser;

async function test() {
browser = await Wendigo.createBrowser();
browser.requests.mock(MAIN_URL, {
body: `


(function(){
fetch("${FETCH_URL}")
.then(() => (document.getElementById('the-id').innerHTML = 'HOORAYYYY'))
})();



HEYYYY


ITZ A SAZ DAY :(



`,
});

const mock = browser.requests.mock(FETCH_URL, {
body: 'hihihihihiihhi',
headers: {
'Access-Control-Allow-Headers ': 'authorization,content-type',
'Access-Control-Allow-Methods': 'PATCH,GET,OPTIONS,POST,PUT',
'Access-Control-Allow-Origin': MAIN_ORIGIN,
'Access-Contro-Allow-Credentials': 'true',
},
});

await browser.wait();
await browser.open(MAIN_URL);
await browser.waitForText('HEYYYY', 5000); // This works
await mock.assert.called(); // This works
await browser.waitForText('HOORAYYYY', 5000); // This doesn't
}

test().finally(() => browser.close());
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.