Skip to content

Commit aaab1e3

Browse files
committed
Fix linting errors after backstage#13392
Signed-off-by: Fredrik Adelöw <[email protected]>
1 parent 3716ae3 commit aaab1e3

File tree

151 files changed

+837
-786
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+837
-786
lines changed

.changeset/renovate-4f0c2e3.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ Note that this major update to the Jest plugin contains some breaking changes.
88
This means that some of your tests may start seeing some new lint errors. [Read
99
about them
1010
here](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md#2700-2022-08-28).
11+
12+
These are mostly possible to fix automatically. You can try to run `yarn backstage-cli repo lint --fix` in your repo root to have most or all of them
13+
corrected.

packages/backend-common/src/cache/CacheManager.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('CacheManager', () => {
6565
const config = new ConfigReader({ backend: {} });
6666
expect(() => {
6767
CacheManager.fromConfig(config);
68-
}).not.toThrowError();
68+
}).not.toThrow();
6969
});
7070

7171
it('throws on unknown cache store', () => {
@@ -74,7 +74,7 @@ describe('CacheManager', () => {
7474
});
7575
expect(() => {
7676
CacheManager.fromConfig(config);
77-
}).toThrowError();
77+
}).toThrow();
7878
});
7979
});
8080

packages/backend-common/src/context/AbortContext.test.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ describe('AbortContext', () => {
3737

3838
expect(child.abortSignal.aborted).toBe(false);
3939
expect(Math.abs(+child.deadline! - deadline)).toBeLessThan(50);
40-
expect(childListener).toBeCalledTimes(0);
40+
expect(childListener).toHaveBeenCalledTimes(0);
4141

4242
jest.advanceTimersByTime(timeout + 1);
4343

4444
expect(child.abortSignal.aborted).toBe(true);
45-
expect(childListener).toBeCalledTimes(1);
45+
expect(childListener).toHaveBeenCalledTimes(1);
4646
});
4747

4848
it('results in minimum deadline when parent triggers sooner', async () => {
@@ -66,15 +66,15 @@ describe('AbortContext', () => {
6666
expect(child.abortSignal.aborted).toBe(false);
6767
expect(Math.abs(+parent.deadline! - parentDeadline)).toBeLessThan(50);
6868
expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50);
69-
expect(parentListener).toBeCalledTimes(0);
70-
expect(childListener).toBeCalledTimes(0);
69+
expect(parentListener).toHaveBeenCalledTimes(0);
70+
expect(childListener).toHaveBeenCalledTimes(0);
7171

7272
jest.advanceTimersByTime(parentTimeout + 1);
7373

7474
expect(parent.abortSignal.aborted).toBe(true);
7575
expect(child.abortSignal.aborted).toBe(true);
76-
expect(parentListener).toBeCalledTimes(1);
77-
expect(childListener).toBeCalledTimes(1);
76+
expect(parentListener).toHaveBeenCalledTimes(1);
77+
expect(childListener).toHaveBeenCalledTimes(1);
7878
});
7979

8080
it('results in minimum deadline when child triggers sooner', async () => {
@@ -98,22 +98,22 @@ describe('AbortContext', () => {
9898
expect(child.abortSignal.aborted).toBe(false);
9999
expect(Math.abs(+parent.deadline! - parentDeadline)).toBeLessThan(50);
100100
expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50);
101-
expect(parentListener).toBeCalledTimes(0);
102-
expect(childListener).toBeCalledTimes(0);
101+
expect(parentListener).toHaveBeenCalledTimes(0);
102+
expect(childListener).toHaveBeenCalledTimes(0);
103103

104104
jest.advanceTimersByTime(childTimeout + 1);
105105

106106
expect(parent.abortSignal.aborted).toBe(false);
107107
expect(child.abortSignal.aborted).toBe(true);
108-
expect(parentListener).toBeCalledTimes(0);
109-
expect(childListener).toBeCalledTimes(1);
108+
expect(parentListener).toHaveBeenCalledTimes(0);
109+
expect(childListener).toHaveBeenCalledTimes(1);
110110

111111
jest.advanceTimersByTime(parentTimeout - childTimeout + 1);
112112

113113
expect(parent.abortSignal.aborted).toBe(true);
114114
expect(child.abortSignal.aborted).toBe(true);
115-
expect(parentListener).toBeCalledTimes(1);
116-
expect(childListener).toBeCalledTimes(1);
115+
expect(parentListener).toHaveBeenCalledTimes(1);
116+
expect(childListener).toHaveBeenCalledTimes(1);
117117
});
118118

119119
it('child carries over parent signal state if parent was already aborted and had no deadline', async () => {
@@ -133,13 +133,13 @@ describe('AbortContext', () => {
133133
child.abortSignal.addEventListener('abort', childListener);
134134

135135
expect(child.abortSignal.aborted).toBe(true);
136-
expect(childListener).toBeCalledTimes(0);
136+
expect(childListener).toHaveBeenCalledTimes(0);
137137
expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50);
138138

139139
jest.advanceTimersByTime(childTimeout + 1);
140140

141141
expect(child.abortSignal.aborted).toBe(true);
142-
expect(childListener).toBeCalledTimes(0); // still
142+
expect(childListener).toHaveBeenCalledTimes(0); // still
143143
});
144144

145145
it('child carries over parent signal state if parent was already aborted and had a deadline', async () => {
@@ -175,15 +175,15 @@ describe('AbortContext', () => {
175175

176176
expect(parent.abortSignal.aborted).toBe(false);
177177
expect(child.abortSignal.aborted).toBe(false);
178-
expect(parentListener).toBeCalledTimes(0);
179-
expect(childListener).toBeCalledTimes(0);
178+
expect(parentListener).toHaveBeenCalledTimes(0);
179+
expect(childListener).toHaveBeenCalledTimes(0);
180180

181181
parentController.abort();
182182

183183
expect(parent.abortSignal.aborted).toBe(true);
184184
expect(child.abortSignal.aborted).toBe(true);
185-
expect(parentListener).toBeCalledTimes(1);
186-
expect(childListener).toBeCalledTimes(1);
185+
expect(parentListener).toHaveBeenCalledTimes(1);
186+
expect(childListener).toHaveBeenCalledTimes(1);
187187
});
188188

189189
it('does not signal parent when child is aborted', async () => {
@@ -201,15 +201,15 @@ describe('AbortContext', () => {
201201

202202
expect(parent.abortSignal.aborted).toBe(false);
203203
expect(child.abortSignal.aborted).toBe(false);
204-
expect(parentListener).toBeCalledTimes(0);
205-
expect(childListener).toBeCalledTimes(0);
204+
expect(parentListener).toHaveBeenCalledTimes(0);
205+
expect(childListener).toHaveBeenCalledTimes(0);
206206

207207
childController.abort();
208208

209209
expect(parent.abortSignal.aborted).toBe(false);
210210
expect(child.abortSignal.aborted).toBe(true);
211-
expect(parentListener).toBeCalledTimes(0);
212-
expect(childListener).toBeCalledTimes(1);
211+
expect(parentListener).toHaveBeenCalledTimes(0);
212+
expect(childListener).toHaveBeenCalledTimes(1);
213213
});
214214

215215
it('child carries over parent signal state if parent was already aborted', async () => {
@@ -227,13 +227,13 @@ describe('AbortContext', () => {
227227

228228
expect(parent.abortSignal.aborted).toBe(true);
229229
expect(child.abortSignal.aborted).toBe(true);
230-
expect(childListener).toBeCalledTimes(0);
230+
expect(childListener).toHaveBeenCalledTimes(0);
231231

232232
childController.abort();
233233

234234
expect(parent.abortSignal.aborted).toBe(true);
235235
expect(child.abortSignal.aborted).toBe(true);
236-
expect(childListener).toBeCalledTimes(0);
236+
expect(childListener).toHaveBeenCalledTimes(0);
237237
});
238238

239239
it('child carries over given signal state if it was already aborted', async () => {
@@ -247,7 +247,7 @@ describe('AbortContext', () => {
247247
child.abortSignal.addEventListener('abort', childListener);
248248

249249
expect(child.abortSignal.aborted).toBe(true);
250-
expect(childListener).toBeCalledTimes(0);
250+
expect(childListener).toHaveBeenCalledTimes(0);
251251
});
252252
});
253253

@@ -267,15 +267,15 @@ describe('AbortContext', () => {
267267

268268
expect(parent.abortSignal.aborted).toBe(false);
269269
expect(child.abortSignal.aborted).toBe(false);
270-
expect(parentListener).toBeCalledTimes(0);
271-
expect(childListener).toBeCalledTimes(0);
270+
expect(parentListener).toHaveBeenCalledTimes(0);
271+
expect(childListener).toHaveBeenCalledTimes(0);
272272

273273
parentController.abort();
274274

275275
expect(parent.abortSignal.aborted).toBe(true);
276276
expect(child.abortSignal.aborted).toBe(true);
277-
expect(parentListener).toBeCalledTimes(1);
278-
expect(childListener).toBeCalledTimes(1);
277+
expect(parentListener).toHaveBeenCalledTimes(1);
278+
expect(childListener).toHaveBeenCalledTimes(1);
279279
});
280280

281281
it('does not signal parent when child is aborted', async () => {
@@ -293,15 +293,15 @@ describe('AbortContext', () => {
293293

294294
expect(parent.abortSignal.aborted).toBe(false);
295295
expect(child.abortSignal.aborted).toBe(false);
296-
expect(parentListener).toBeCalledTimes(0);
297-
expect(childListener).toBeCalledTimes(0);
296+
expect(parentListener).toHaveBeenCalledTimes(0);
297+
expect(childListener).toHaveBeenCalledTimes(0);
298298

299299
childController.abort();
300300

301301
expect(parent.abortSignal.aborted).toBe(false);
302302
expect(child.abortSignal.aborted).toBe(true);
303-
expect(parentListener).toBeCalledTimes(0);
304-
expect(childListener).toBeCalledTimes(1);
303+
expect(parentListener).toHaveBeenCalledTimes(0);
304+
expect(childListener).toHaveBeenCalledTimes(1);
305305
});
306306

307307
it('child carries over parent signal state if parent was already aborted', async () => {
@@ -319,13 +319,13 @@ describe('AbortContext', () => {
319319

320320
expect(parent.abortSignal.aborted).toBe(true);
321321
expect(child.abortSignal.aborted).toBe(true);
322-
expect(childListener).toBeCalledTimes(0);
322+
expect(childListener).toHaveBeenCalledTimes(0);
323323

324324
childController.abort();
325325

326326
expect(parent.abortSignal.aborted).toBe(true);
327327
expect(child.abortSignal.aborted).toBe(true);
328-
expect(childListener).toBeCalledTimes(0);
328+
expect(childListener).toHaveBeenCalledTimes(0);
329329
});
330330

331331
it('child carries over given signal state if it was already aborted', async () => {
@@ -339,7 +339,7 @@ describe('AbortContext', () => {
339339
child.abortSignal.addEventListener('abort', childListener);
340340

341341
expect(child.abortSignal.aborted).toBe(true);
342-
expect(childListener).toBeCalledTimes(0);
342+
expect(childListener).toHaveBeenCalledTimes(0);
343343
});
344344
});
345345
});

packages/backend-common/src/database/connection.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('database connection', () => {
110110
connection: '',
111111
}),
112112
),
113-
).toThrowError();
113+
).toThrow();
114114
});
115115

116116
it('throws an error without a connection', () => {
@@ -120,7 +120,7 @@ describe('database connection', () => {
120120
client: 'pg',
121121
}),
122122
),
123-
).toThrowError();
123+
).toThrow();
124124
});
125125
});
126126

@@ -147,7 +147,7 @@ describe('database connection', () => {
147147
});
148148

149149
it('throws an error for unknown connection', () => {
150-
expect(() => createNameOverride('unknown', 'testname')).toThrowError();
150+
expect(() => createNameOverride('unknown', 'testname')).toThrow();
151151
});
152152
});
153153

packages/backend-common/src/database/connectors/postgres.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ describe('postgres', () => {
194194
'postgresql://postgres:pass@localhost:5432/dbname?sslrootcert=/path/to/file',
195195
),
196196
),
197-
).toThrowError(/no such file or directory/);
197+
).toThrow(/no such file or directory/);
198198
});
199199
});
200200

packages/backend-common/src/reading/GithubUrlReader.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ describe('GithubUrlReader', () => {
551551
credentialsProvider: mockCredentialsProvider,
552552
},
553553
);
554-
}).toThrowError('must configure an explicit apiBaseUrl');
554+
}).toThrow('must configure an explicit apiBaseUrl');
555555
});
556556
});
557557

packages/backend-common/src/reading/GoogleGcsUrlReader.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe('GcsUrlReader', () => {
127127

128128
it('throws if search url looks truly glob-y', async () => {
129129
const glob = 'https://storage.cloud.google.com/bucket/**/path*';
130-
await expect(() => reader.search(glob)).rejects.toThrowError(
130+
await expect(() => reader.search(glob)).rejects.toThrow(
131131
'GcsUrlReader only supports prefix-based searches',
132132
);
133133
});

packages/backend-common/src/reading/ReadUrlResponseFactory.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('ReadUrlResponseFactory', () => {
5555
it('buffer cannot be called after stream is called', async () => {
5656
const response = await ReadUrlResponseFactory.fromReadable(readable);
5757
response.stream!();
58-
expect(() => response.buffer()).toThrowError(ConflictError);
58+
expect(() => response.buffer()).toThrow(ConflictError);
5959
});
6060

6161
it('stream returns expected data', async () => {
@@ -68,7 +68,7 @@ describe('ReadUrlResponseFactory', () => {
6868
it('stream cannot be called after buffer is called', async () => {
6969
const response = await ReadUrlResponseFactory.fromReadable(readable);
7070
response.buffer();
71-
expect(() => response.stream!()).toThrowError(ConflictError);
71+
expect(() => response.stream!()).toThrow(ConflictError);
7272
});
7373
});
7474

packages/backend-common/src/reading/UrlReaderPredicateMux.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('UrlReaderPredicateMux', () => {
6464
it('throws an error if no predicate matches', async () => {
6565
const mux = new UrlReaderPredicateMux(getVoidLogger());
6666

67-
await expect(mux.readUrl('http://foo/1')).rejects.toThrowError(
67+
await expect(mux.readUrl('http://foo/1')).rejects.toThrow(
6868
/^Reading from 'http:\/\/foo\/1' is not allowed. You may/,
6969
);
7070

@@ -80,7 +80,7 @@ describe('UrlReaderPredicateMux', () => {
8080

8181
await expect(mux.readUrl('http://foo/1')).resolves.toBeUndefined();
8282

83-
await expect(mux.readUrl('http://bar/1')).rejects.toThrowError(
83+
await expect(mux.readUrl('http://bar/1')).rejects.toThrow(
8484
/^Reading from 'http:\/\/bar\/1' is not allowed. You may/,
8585
);
8686
});

packages/backend-common/src/tokens/ServerTokenManager.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ describe('ServerTokenManager', () => {
6666
const tokenManager = ServerTokenManager.fromConfig(configWithSecret, {
6767
logger,
6868
});
69-
await expect(
70-
tokenManager.authenticate('random-string'),
71-
).rejects.toThrowError(/invalid server token/i);
69+
await expect(tokenManager.authenticate('random-string')).rejects.toThrow(
70+
/invalid server token/i,
71+
);
7272
});
7373

7474
it('should validate server tokens created by a different instance using the same secret', async () => {
@@ -129,7 +129,7 @@ describe('ServerTokenManager', () => {
129129

130130
const { token } = await tokenManager1.getToken();
131131

132-
await expect(tokenManager2.authenticate(token)).rejects.toThrowError(
132+
await expect(tokenManager2.authenticate(token)).rejects.toThrow(
133133
/invalid server token/i,
134134
);
135135
});
@@ -145,7 +145,7 @@ describe('ServerTokenManager', () => {
145145

146146
const { token } = await noopTokenManager.getToken();
147147

148-
await expect(tokenManager.authenticate(token)).rejects.toThrowError(
148+
await expect(tokenManager.authenticate(token)).rejects.toThrow(
149149
/invalid server token/i,
150150
);
151151
});
@@ -164,7 +164,7 @@ describe('ServerTokenManager', () => {
164164

165165
const { token } = await tokenManager2.getToken();
166166

167-
await expect(tokenManager1.authenticate(token)).rejects.toThrowError(
167+
await expect(tokenManager1.authenticate(token)).rejects.toThrow(
168168
/invalid server token/i,
169169
);
170170
});

0 commit comments

Comments
 (0)