Unverified Commit 56d17c4e authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Skip browserslistrc tests (#61294)

## What?

Fixes the condition to correctly test if browserslist is applied in both
webpack and Turbopack.

Skips the test because `.browserslistrc` is not supported yet and will
be added after stable.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2277
parent f854497c
......@@ -5,16 +5,17 @@ import path from 'path'
import cheerio from 'cheerio'
const appDir = path.join(__dirname, 'app')
describe('Browserslist', () => {
// TODO: This test needs to check multiple files and syntax features.
describe.skip('Browserslist', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(path.join(appDir, 'pages')),
'.browserslistrc': 'Chrome 73',
// In Chrome 45 arrow functions are introduced, by
'.browserslistrc': 'Chrome 42',
},
dependencies: {},
})
})
afterAll(() => next.destroy())
......@@ -23,21 +24,23 @@ describe('Browserslist', () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
let finished = false
await Promise.all(
$('script')
.toArray()
.map(async (el) => {
const src = $(el).attr('src')
if (!src) return
if (src.includes('/index')) {
const res = await fetchViaHTTP(next.url, src)
const code = await res.text()
expect(code).toMatch('()=>')
finished = true
}
})
)
expect(finished).toBe(true)
expect(
(
await Promise.all(
$('script')
.toArray()
.map(async (el) => {
const src = $(el).attr('src')
const res = await fetchViaHTTP(next.url, src)
const code = await res.text()
if (code.includes('async ()=>')) {
return src
}
return false
})
)
) // Filter out false values
.filter((item) => item)
).toBeEmpty()
})
})
......@@ -5,7 +5,8 @@ import path from 'path'
import cheerio from 'cheerio'
const appDir = path.join(__dirname, 'app')
describe('default browserslist target', () => {
// TODO: This test needs to check multiple files and syntax features.
describe.skip('default browserslist target', () => {
let next: NextInstance
beforeAll(async () => {
......@@ -13,7 +14,6 @@ describe('default browserslist target', () => {
files: {
pages: new FileRef(path.join(appDir, 'pages')),
},
dependencies: {},
})
})
afterAll(() => next.destroy())
......@@ -22,21 +22,25 @@ describe('default browserslist target', () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
let finished = false
await Promise.all(
$('script')
.toArray()
.map(async (el) => {
const src = $(el).attr('src')
if (!src) return
if (src.includes('/index')) {
const res = await fetchViaHTTP(next.url, src)
const code = await res.text()
expect(code).toMatch('()=>')
finished = true
}
})
)
expect(finished).toBe(true)
expect(
(
await Promise.all(
$('script')
.toArray()
.map(async (el) => {
const src = $(el).attr('src')
const res = await fetchViaHTTP(next.url, src)
const code = await res.text()
// Default compiles for ES Modules output
if (code.includes('async ()=>')) {
return src
}
return false
})
)
)
// Filter out false values
.filter((item) => item)
).not.toBeEmpty()
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment