rsnext/test/e2e/app-dir/webpack-loader-conditions/webpack-loader-conditions.test.ts
Tobias Koppers 43d911406b
add conditions for webpack loader rules (#63333)
### What?

* Allow to apply webpack loaders depending on "conditions".
* add a few next specific conditions depending on context type

### Why?

Some loaders need different behavior depending on context

### How?


Closes PACK-2748
2024-03-16 21:02:10 +01:00

26 lines
882 B
TypeScript

import { nextTestSetup } from 'e2e-utils'
describe('webpack-loader-conditions', () => {
const { next, isTurbopack } = nextTestSetup({
files: __dirname,
})
if (!isTurbopack) {
it('should only run the test in turbopack', () => {})
return
}
it('should render correctly on server site', async () => {
const res = await next.fetch('/')
const html = (await res.text()).replaceAll(/<!-- -->/g, '')
expect(html).toContain(`server: {&quot;default&quot;:true}`)
expect(html).toContain(`client: {&quot;nextSsr&quot;:true}`)
})
it('should render correctly on client side', async () => {
const browser = await next.browser('/')
const text = await browser.elementByCss('body').text()
expect(text).toContain(`server: ${JSON.stringify({ default: true })}`)
expect(text).toContain(`client: ${JSON.stringify({ browser: true })}`)
})
})