-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathenhanced.spec.ts
28 lines (25 loc) · 981 Bytes
/
enhanced.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
describe('Enhanced middleware', () => {
it('adds request headers', () => {
cy.request('/api/hello').then((response) => {
expect(response.body).to.have.nested.property('headers.x-hello', 'world')
})
})
it('adds request headers to a rewrite', () => {
cy.request('/headers').then((response) => {
expect(response.body).to.have.nested.property('headers.x-hello', 'world')
})
})
it('rewrites the response body', () => {
cy.visit('/static')
cy.get('#message').contains('This was static but has been transformed in')
cy.contains("This is an ad that isn't shown by default")
})
it('modifies the page props', () => {
cy.request('/_next/data/build-id/static.json').then((response) => {
expect(response.body).to.have.nested.property('pageProps.showAd', true)
expect(response.body)
.to.have.nested.property('pageProps.message')
.that.includes('This was static but has been transformed in')
})
})
})