Skip to content

Commit

Permalink
test(e2e): move css-modules test cases to builder (#4016)
Browse files Browse the repository at this point in the history
Co-authored-by: Asuka109 <chenwenjie.asuka@bytedance.com>
  • Loading branch information
chenjiahan and Asuka109 committed Jun 20, 2023
1 parent 7073297 commit 1ebbbb7
Show file tree
Hide file tree
Showing 33 changed files with 78 additions and 429 deletions.
90 changes: 0 additions & 90 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions tests/e2e/builder/cases/css/css-modules-composes/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import path from 'path';
import { expect, test } from '@modern-js/e2e/playwright';
import { build } from '@scripts/shared';

test('should compile CSS modules composes correctly', async () => {
const builder = await build({
cwd: __dirname,
entry: { index: path.resolve(__dirname, './src/index.js') },
});
const files = await builder.unwrapOutputJSON();

const content =
files[Object.keys(files).find(file => file.endsWith('.css'))!];

if (builder.providerType === 'rspack') {
expect(content).toMatch(
/.*\{background:red;color:yellow\}.*\{background:blue\}/,
);
} else {
expect(content).toMatch(
/.*\{background:red;color:#ff0\}.*\{background:blue\}/,
);
}
});

test('should compile CSS modules composes with external correctly', async () => {
const builder = await build({
cwd: __dirname,
entry: { external: path.resolve(__dirname, './src/external.js') },
});
const files = await builder.unwrapOutputJSON();

const content =
files[Object.keys(files).find(file => file.endsWith('.css'))!];

if (builder.providerType === 'rspack') {
expect(content).toMatch(
/.*\{background:cyan;color:black\}.*\{background:green\}/,
);
} else {
expect(content).toMatch(
/.*\{background:cyan;color:#000\}.*\{background:green\}/,
);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import styles from './external.module.css';

console.log(styles);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.subClass2 {
composes: className from './other.module.css';
background: green;
}
3 changes: 3 additions & 0 deletions tests/e2e/builder/cases/css/css-modules-composes/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import styles from './index.module.css';

console.log(styles);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.className {
background: cyan;
color: black;
}
18 changes: 18 additions & 0 deletions tests/e2e/builder/cases/css/css-modules-global/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import path from 'path';
import { expect, test } from '@modern-js/e2e/playwright';
import { build } from '@scripts/shared';

test('should compile CSS modules with :global() correctly', async () => {
const builder = await build({
cwd: __dirname,
entry: { index: path.resolve(__dirname, './src/index.js') },
});
const files = await builder.unwrapOutputJSON();

const content =
files[Object.keys(files).find(file => file.endsWith('.css'))!];

expect(content).toMatch(
/.*\{position:relative\}.* \.bar,.* \.baz\{height:100%;overflow:hidden\}.* \.lol{width:80%}/,
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './a.module.css';

This file was deleted.

11 changes: 0 additions & 11 deletions tests/integration/css-modules/fixtures/composes-basic/package.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/integration/css-modules/fixtures/composes-basic/src/App.jsx

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions tests/integration/css-modules/fixtures/dev-module/package.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/integration/css-modules/fixtures/dev-module/src/App.jsx

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions tests/integration/css-modules/fixtures/global-module/package.json

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions tests/integration/css-modules/fixtures/prod-module/package.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/integration/css-modules/fixtures/prod-module/src/App.jsx

This file was deleted.

This file was deleted.

Empty file.
11 changes: 0 additions & 11 deletions tests/integration/css-modules/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/integration/css-modules/readme.md

This file was deleted.

Loading

0 comments on commit 1ebbbb7

Please sign in to comment.