const systemTests = require('../lib/system-tests').default const { stripIndent } = require('common-tags') const bodyParser = require('body-parser') const onServer = function (app) { app.use(bodyParser.json({ extended: false })) app.get('/get-json', (req, res) => { return res.json([1, 2, 3]) }) app.get('/get-text', (req, res) => { return res.send('pong') }) app.post('/add', (req, res) => { if (req.body.method !== 'add') { throw new Error('wrong body method') } return res.json({ answer: req.body.a + req.body.b }) }) // page posts a JSON object app.get('/addition', (req, res) => { return res.send(stripIndent`
`) }) // page fetches JSON array app.get('/first', (req, res) => { return res.send(stripIndent` second `) }) // page fetches text app.get('/second', (req, res) => { return res.send(stripIndent`
`) }) } describe('e2e fetch polyfill', () => { systemTests.setup({ servers: { port: 1818, onServer, }, }) systemTests.it('passes', { spec: 'fetch.cy.js', snapshot: false, config: { experimentalFetchPolyfill: true, }, }) }) describe('e2e no fetch polyfill', () => { systemTests.setup({ servers: { port: 1818, onServer, }, }) systemTests.it('passes', { spec: 'fetch_no_polyfill.cy.js', snapshot: false, config: { experimentalFetchPolyfill: false, }, }) })