You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('Smelly Test Smell Detection Suite',()=>{
16
+
test.each([[{
18
17
code: `const a = 1;
19
18
if (a === 1) {}`,
20
19
language: JAVASCRIPT,
@@ -27,8 +26,8 @@ if (a === 1) {}`,
27
26
total: 1,
28
27
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
29
28
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
30
-
},
31
-
{
29
+
}],
30
+
[{
32
31
code: `const lists = [{}, {}];
33
32
34
33
for (const i of lists) {
@@ -44,8 +43,8 @@ for (const i of lists) {
44
43
total: 1,
45
44
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
46
45
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`
47
-
},
48
-
{
46
+
}],
47
+
[{
49
48
code: `const lists = [{}, {}];
50
49
51
50
for (const i in lists) {
@@ -61,8 +60,8 @@ for (const i in lists) {
61
60
total: 1,
62
61
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
63
62
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`
64
-
},
65
-
{
63
+
}],
64
+
[{
66
65
code: `const lists = [{}, {}];
67
66
68
67
for (let i = 0; i < 1; i++) {
@@ -78,8 +77,8 @@ for (let i = 0; i < 1; i++) {
78
77
total: 1,
79
78
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
80
79
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`
81
-
},
82
-
{
80
+
}],
81
+
[{
83
82
code: `setTimeout(() => {
84
83
done();
85
84
});`,
@@ -93,8 +92,8 @@ for (let i = 0; i < 1; i++) {
93
92
total: 1,
94
93
description: `Smelly: Avoid using setTimeouts for tests. It might lead to Sleepy test or undeterministic behaviour based on where the test is executed.`,
95
94
diagnostic: `Smelly: Avoid using setTimeouts for tests. It might lead to Sleepy test or undeterministic behaviour based on where the test is executed`,
96
-
},
97
-
{
95
+
}],
96
+
[{
98
97
code: `function done() {};
99
98
setTimeout(() => {
100
99
done();
@@ -109,8 +108,8 @@ setTimeout(() => {
109
108
total: 1,
110
109
description: `Smelly: Avoid using setTimeouts for tests. It might lead to Sleepy test or undeterministic behaviour based on where the test is executed.`,
111
110
diagnostic: `Smelly: Avoid using setTimeouts for tests. It might lead to Sleepy test or undeterministic behaviour based on where the test is executed`,
112
-
},
113
-
{
111
+
}],
112
+
[{
114
113
code: `const a: number = 1;
115
114
if (a === 1) { }`,
116
115
language: TYPESCRIPT,
@@ -123,8 +122,8 @@ if (a === 1) { }`,
123
122
total: 1,
124
123
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
125
124
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
126
-
},
127
-
{
125
+
}],
126
+
[{
128
127
129
128
code: `const a: number = 1;
130
129
if (a === 1) { }
@@ -141,8 +140,8 @@ if (a === 2) {
141
140
total: 3,
142
141
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
143
142
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
144
-
},
145
-
{
143
+
}],
144
+
[{
146
145
code: `const lists: any[] = [{}, {}];
147
146
148
147
for (const i of lists) {
@@ -158,8 +157,8 @@ for (const i of lists) {
158
157
total: 1,
159
158
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
160
159
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`
161
-
},
162
-
{
160
+
}],
161
+
[{
163
162
code: `const lists: any[] = [{}, {}];
164
163
165
164
for (const i in lists) {
@@ -175,8 +174,8 @@ for (const i in lists) {
175
174
total: 1,
176
175
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
177
176
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`
178
-
},
179
-
{
177
+
}],
178
+
[{
180
179
code: `const lists: any[] = [{}, {}];
181
180
182
181
for (let i =0; i < 2; i++) {
@@ -192,8 +191,8 @@ for (let i =0; i < 2; i++) {
192
191
total: 1,
193
192
description: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`,
194
193
diagnostic: `Smelly: Avoid Conditional Test Logic in the test. Having conditional logic points to a test case that requires different context to run. Split the test case to fit one context per test case.`
195
-
},
196
-
{
194
+
}],
195
+
[{
197
196
code: `setTimeout(() => {
198
197
done();
199
198
});`,
@@ -207,8 +206,8 @@ for (let i =0; i < 2; i++) {
207
206
total: 1,
208
207
description: `Smelly: Avoid using setTimeouts for tests. It might lead to Sleepy test or undeterministic behaviour based on where the test is executed.`,
209
208
diagnostic: `Smelly: Avoid using setTimeouts for tests. It might lead to Sleepy test or undeterministic behaviour based on where the test is executed`,
210
-
},
211
-
{
209
+
}],
210
+
[{
212
211
code: `function done() {};
213
212
setTimeout(() => {
214
213
done();
@@ -223,8 +222,8 @@ setTimeout(() => {
223
222
total: 1,
224
223
description: `Smelly: Avoid using setTimeouts for tests. It might lead to Sleepy test or undeterministic behaviour based on where the test is executed.`,
225
224
diagnostic: `Smelly: Avoid using setTimeouts for tests. It might lead to Sleepy test or undeterministic behaviour based on where the test is executed`,
226
-
},
227
-
{
225
+
}],
226
+
[{
228
227
code: `describe("my test", () => {
229
228
it("a", () => {
230
229
console.log(1);
@@ -240,8 +239,8 @@ console.log(1);
240
239
total: 1,
241
240
description: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
242
241
diagnostic: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
243
-
},
244
-
{
242
+
}],
243
+
[{
245
244
code: `describe("my test", () => {
246
245
it("a", () => {
247
246
console.log(1);
@@ -257,8 +256,8 @@ console.log(1);
257
256
total: 1,
258
257
description: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
259
258
diagnostic: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
260
-
},
261
-
{
259
+
}],
260
+
[{
262
261
code: `describe("my test", () => {
263
262
it("a", () => {
264
263
console.error(1);
@@ -274,8 +273,8 @@ console.error(1);
274
273
total: 1,
275
274
description: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
276
275
diagnostic: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
277
-
},
278
-
{
276
+
}],
277
+
[{
279
278
code: `describe("my test", () => {
280
279
it("a", () => {
281
280
console.info(1);
@@ -291,8 +290,8 @@ console.info(1);
291
290
total: 1,
292
291
description: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
293
292
diagnostic: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
294
-
},
295
-
{
293
+
}],
294
+
[{
296
295
code: `describe("my test", () => {
297
296
it("a", () => {
298
297
console.info(1);
@@ -308,8 +307,8 @@ console.info(1);
308
307
total: 1,
309
308
description: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
310
309
diagnostic: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
311
-
},
312
-
{
310
+
}],
311
+
[{
313
312
code: `describe("my test", () => {
314
313
it("a", () => {
315
314
console.error(1);
@@ -325,8 +324,8 @@ console.error(1);
325
324
total: 1,
326
325
description: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
327
326
diagnostic: `Smelly: Avoid poluting the test output. It is known as the loudmouth`,
328
-
},
329
-
{
327
+
}],
328
+
[{
330
329
code: `jest.mock("../");
331
330
jest.mock("../");
332
331
jest.mock("../");
@@ -347,8 +346,8 @@ jest.mock("../");`,
347
346
total: 1,
348
347
description: `Smelly: Avoid mocking too many dependencies in the test file. Split the test cases to distribute the mocking load.`,
349
348
diagnostic: `Smelly: Avoid mocking too many dependencies in the test file. Split the test cases to distribute the mocking load.`,
350
-
},
351
-
{
349
+
}],
350
+
[{
352
351
code: `jest.mock("../");
353
352
jest.mock("../");
354
353
jest.mock("../");
@@ -370,34 +369,30 @@ jest.mock("../");`,
370
369
total: 1,
371
370
description: `Smelly: Avoid mocking too many dependencies in the test file. Split the test cases to distribute the mocking load.`,
372
371
diagnostic: `Smelly: Avoid mocking too many dependencies in the test file. Split the test cases to distribute the mocking load.`,
])(`detect test smell for %s %s: type %s %s at index %s`,({ code, language, index, type, lineStart, lineEnd, startAt, endsAt, total, description, diagnostic })=>{
0 commit comments