Skip to content

Commit 46d5ec0

Browse files
authored
Merge pull request #334 from DaleStudy/264-fix-config
eslint-plugin-testing-library ์„ค์ • ๋ฌธ์ œ
2 parents d0c229b + aa4679c commit 46d5ec0

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

โ€Žeslint.config.jsโ€Ž

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ export default tseslint.config(
2828
},
2929
{
3030
files: ["src/components/**/*.test.[jt]s?(x)"],
31-
languageOptions: {
32-
ecmaVersion: 2020,
33-
globals: {
34-
...globals.browser,
35-
...globals.vitest,
36-
},
37-
},
38-
plugins: {
39-
"testing-library": testingLibrary,
40-
},
41-
rules: {
42-
"testing-library/await-async-queries": "error",
43-
"testing-library/no-debugging-utils": "warn",
44-
"testing-library/no-dom-import": "off",
45-
},
31+
...testingLibrary.configs["flat/react"],
4632
},
4733
);

โ€Žsrc/components/Checkbox/Checkbox.test.tsxโ€Ž

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,16 @@ test("disabled ์†์„ฑ์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ ์šฉ๋จ", () => {
9696
test("ํ•„์ˆ˜ ํ‘œ์‹œ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ํ‘œ์‹œ๋จ", () => {
9797
render(<Required />);
9898

99-
const requiredLabel = screen.getByText("ํ•„์ˆ˜ ์ฒดํฌ๋ฐ•์Šค").parentElement;
100-
const optionalLabel = screen.getByText("์„ ํƒ ์ฒดํฌ๋ฐ•์Šค");
101-
102-
// Check for required indicator (asterisk)
103-
expect(requiredLabel).toContainHTML("*");
104-
expect(optionalLabel).not.toContainHTML("*");
99+
expect(
100+
screen.getByRole("checkbox", {
101+
name: "ํ•„์ˆ˜ ์ฒดํฌ๋ฐ•์Šค *",
102+
}),
103+
).toBeInTheDocument();
104+
expect(
105+
screen.getByRole("checkbox", {
106+
name: "์„ ํƒ ์ฒดํฌ๋ฐ•์Šค",
107+
}),
108+
).toBeInTheDocument();
105109
});
106110

107111
test("์ฒดํฌ๋ฐ•์Šค ํด๋ฆญ ์‹œ, onChange ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ํ˜ธ์ถœ๋จ", async () => {

โ€Žsrc/components/Icon/Icon.test.tsxโ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const { Basic } = composeStories(stories);
88
test("SVG ์š”์†Œ๋ฅผ ๋ Œ๋”๋งํ•œ๋‹ค", () => {
99
const { container } = render(<Basic />);
1010

11+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
1112
expect(container.querySelector("svg")).toBeInTheDocument();
1213
});
1314

@@ -20,6 +21,7 @@ test.each([
2021
] as const)("%s ํฌ๊ธฐ์— ์˜ฌ๋ฐ”๋ฅธ ํด๋ž˜์Šค๋ฅผ ์ ์šฉํ•œ๋‹ค", (size, className) => {
2122
const { container } = render(<Basic size={size} />);
2223

24+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
2325
expect(container.querySelector("svg")).toHaveClass(className);
2426
});
2527

@@ -33,6 +35,7 @@ test.each([
3335
] as const)("%s ํ†ค์— ์˜ฌ๋ฐ”๋ฅธ ์ƒ‰์ƒ ํด๋ž˜์Šค๋ฅผ ์ ์šฉํ•œ๋‹ค", (tone, className) => {
3436
const { container } = render(<Basic tone={tone} muted={false} />);
3537

38+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
3639
expect(container.querySelector("svg")).toHaveClass(className);
3740
});
3841

@@ -42,6 +45,7 @@ test.each([
4245
] as const)("muted๊ฐ€ %s์ผ ๋•Œ ์˜ฌ๋ฐ”๋ฅธ ํด๋ž˜์Šค๋ฅผ ์ ์šฉํ•œ๋‹ค", (muted, className) => {
4346
const { container } = render(<Basic tone="neutral" muted={muted} />);
4447

48+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
4549
expect(container.querySelector("svg")).toHaveClass(className);
4650
});
4751

@@ -62,6 +66,7 @@ test.each([
6266
"%s ํ†ค๊ณผ muted=%s ์กฐํ•ฉ์œผ๋กœ SVG ์š”์†Œ๋ฅผ ๋ Œ๋”๋งํ•œ๋‹ค",
6367
(tone, muted) => {
6468
const { container } = render(<Basic tone={tone} muted={muted} />);
69+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
6570
const svg = container.querySelector("svg");
6671

6772
expect(svg).toBeInTheDocument();
@@ -83,6 +88,7 @@ test.each([
8388
["info", true],
8489
] as const)("%s ํ†ค๊ณผ muted=%s ์กฐํ•ฉ์œผ๋กœ class ์†์„ฑ์„ ๊ฐ€์ง„๋‹ค", (tone, muted) => {
8590
const { container } = render(<Basic tone={tone} muted={muted} />);
91+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
8692
const svg = container.querySelector("svg");
8793

8894
expect(svg).toHaveAttribute("class");
@@ -105,6 +111,7 @@ test.each([
105111
"%s ํ†ค๊ณผ muted=%s ์กฐํ•ฉ์œผ๋กœ ์ƒ‰์ƒ ํด๋ž˜์Šค๋ฅผ ํฌํ•จํ•œ๋‹ค",
106112
(tone, muted) => {
107113
const { container } = render(<Basic tone={tone} muted={muted} />);
114+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
108115
const svg = container.querySelector("svg");
109116

110117
const hasColorClass = Array.from(svg?.classList || []).some(

โ€Žsrc/components/Link/Link.test.tsxโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe("๋ Œ๋”๋ง ํ…Œ์ŠคํŠธ", () => {
2020

2121
const link = screen.getByRole("link");
2222
expect(link).toHaveTextContent("๋งํฌ");
23+
// eslint-disable-next-line testing-library/no-node-access
2324
expect(link.querySelector("svg")).toBeInTheDocument();
2425
});
2526
});

โ€Žsrc/components/RadioGroup/RadioGroup.test.tsxโ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ describe("Radio", () => {
203203
const radio = screen.getByRole("radio", { name: "Option 1" });
204204
expect(radio).toBeInTheDocument();
205205

206+
// eslint-disable-next-line testing-library/no-node-access
206207
const container = radio.closest("label");
207208
expect(
209+
// eslint-disable-next-line testing-library/no-node-access
208210
container?.querySelector('div[class*="border"]'),
209211
).toBeInTheDocument();
210212
});

0 commit comments

Comments
ย (0)