rsnext/test/e2e/app-dir/scss/external-url
Tim Neutkens c0b1383c39
Migrate Sass tests to test/e2e (#62321)
## What?

Migrates the Sass support tests from `test/integration` (legacy test
suite) to `test/e2e`, this way all these tests run against both
development and production, whereas previously most of them would only
run against production.

This is helpful as it ensures the tests are running against Turbopack
too, which is highlighting some missing features in Sass support for
Turbopack.

I've had to rewrite most of the tests to check against the actual
rendered output in the browser instead of CSS output in the `.next`
folder, the majority of these now run regardless of implementation
details.

<details>
<summary>Tests that failed with Turbopack</summary>

```
 FAIL  e2e/app-dir/scss/url-global-partial/url-global-partial.test.ts (84.9 s)
  ● SCSS Support loader handling › CSS URL via file-loader sass partial › should render the page

    thrown: "Exceeded timeout of 60000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      13 |     })
      14 |
    > 15 |     it('should render the page', async () => {
         |     ^
      16 |       const browser = await next.browser('/')
      17 |       expect(
      18 |         await browser.elementByCss('.red-text').getComputedCss('color')

      at it (e2e/app-dir/scss/url-global-partial/url-global-partial.test.ts:15:5)
      at describe (e2e/app-dir/scss/url-global-partial/url-global-partial.test.ts:7:3)
      at Object.describe (e2e/app-dir/scss/url-global-partial/url-global-partial.test.ts:6:1)

 FAIL  e2e/app-dir/scss/composes-external/composes-external.test.ts (84.765 s)
  ● CSS Module Composes Usage (External) › should render the module

    thrown: "Exceeded timeout of 60000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      12 |   })
      13 |
    > 14 |   it('should render the module', async () => {
         |   ^
      15 |     const browser = await next.browser('/')
      16 |     expect(
      17 |       await browser.elementByCss('#verify-yellow').getComputedCss('color')

      at it (e2e/app-dir/scss/composes-external/composes-external.test.ts:14:3)
      at Object.describe (e2e/app-dir/scss/composes-external/composes-external.test.ts:6:1)

 FAIL  e2e/app-dir/scss/composes-basic/composes-basic.test.ts (35.629 s)
  ● CSS Module Composes Usage (Basic) › should render the module

    expect(received).toBe(expected) // Object.is equality

    Expected: "rgb(255, 255, 0)"
    Received: "rgb(0, 0, 0)"

      16 |     expect(
      17 |       await browser.elementByCss('#verify-yellow').getComputedCss('color')
    > 18 |     ).toBe(colorToRgb('yellow'))
         |       ^
      19 |     expect(
      20 |       await browser
      21 |         .elementByCss('#verify-yellow')

      at Object.toBe (e2e/app-dir/scss/composes-basic/composes-basic.test.ts:18:7)

 FAIL  e2e/app-dir/scss/npm-import-nested/npm-import-nested.test.ts (90.889 s)
  ● Good Nested CSS Import from node_modules › should render the page

    thrown: "Exceeded timeout of 60000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      12 |   })
      13 |
    > 14 |   it('should render the page', async () => {
         |   ^
      15 |     const browser = await next.browser('/')
      16 |     expect(
      17 |       await browser.elementByCss('.red-text').getComputedCss('color')

      at it (e2e/app-dir/scss/npm-import-nested/npm-import-nested.test.ts:14:3)
      at Object.describe (e2e/app-dir/scss/npm-import-nested/npm-import-nested.test.ts:6:1)

 FAIL  e2e/app-dir/scss/nm-module-nested/nm-module-nested.test.ts (81.941 s)
  ● Valid Nested CSS Module Usage from within node_modules › should render the page

    thrown: "Exceeded timeout of 60000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      12 |   })
      13 |
    > 14 |   it('should render the page', async () => {
         |   ^
      15 |     const browser = await next.browser('/')
      16 |     expect(await browser.elementByCss('#other2').getComputedCss('color')).toBe(
      17 |       colorToRgb('red')

      at it (e2e/app-dir/scss/nm-module-nested/nm-module-nested.test.ts:14:3)
      at Object.describe (e2e/app-dir/scss/nm-module-nested/nm-module-nested.test.ts:6:1)

```

</details>

<!-- 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-2550

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-03-01 09:43:21 +00:00
..
pages Migrate Sass tests to test/e2e (#62321) 2024-03-01 09:43:21 +00:00
styles Migrate Sass tests to test/e2e (#62321) 2024-03-01 09:43:21 +00:00
external-url.test.ts Migrate Sass tests to test/e2e (#62321) 2024-03-01 09:43:21 +00:00