Skip to content

Commit df938ff

Browse files
committed
fix: resolve ESLint errors in wrapper tests
Fix @typescript-eslint/no-unused-expressions errors by adding void keyword to Chai expect assertions and remove unused variable. Changes: - Add 'void' to all standalone expect() assertions in test files - Comment out unused 'apiTest' variable in integration.test.ts - All tests still pass with proper linting Resolves ESLint errors: - CaptureContext.test.ts: 10 expression errors - integration.test.ts: 2 errors (unused var + expression) - interceptedRequest.test.ts: 1 expression error
1 parent 27ee5e9 commit df938ff

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

lib/wrappers/__tests__/CaptureContext.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,35 @@ import { CaptureContext } from "../core/CaptureContext"
2121
describe("CaptureContext", () => {
2222
describe("isActive", () => {
2323
it("should return false when not in context", () => {
24-
expect(CaptureContext.isActive()).to.be.false
24+
void expect(CaptureContext.isActive()).to.be.false
2525
})
2626

2727
it("should return true when in context", () => {
2828
CaptureContext.run("test", undefined, () => {
29-
expect(CaptureContext.isActive()).to.be.true
29+
void expect(CaptureContext.isActive()).to.be.true
3030
})
3131
})
3232

3333
it("should return false after context ends", () => {
3434
CaptureContext.run("test", undefined, () => {
3535
// inside context
3636
})
37-
expect(CaptureContext.isActive()).to.be.false
37+
void expect(CaptureContext.isActive()).to.be.false
3838
})
3939
})
4040

4141
describe("getStore", () => {
4242
it("should return undefined when not in context", () => {
43-
expect(CaptureContext.getStore()).to.be.undefined
43+
void expect(CaptureContext.getStore()).to.be.undefined
4444
})
4545

4646
it("should return store when in context", () => {
4747
CaptureContext.run("test description", { summary: "Test" }, () => {
4848
const store = CaptureContext.getStore()
49-
expect(store).to.not.be.undefined
50-
expect(store?.description).to.equal("test description")
51-
expect(store?.metadata?.summary).to.equal("Test")
52-
expect(store?.capturedRequests).to.be.an("array").that.is.empty
49+
void expect(store).to.not.be.undefined
50+
void expect(store?.description).to.equal("test description")
51+
void expect(store?.metadata?.summary).to.equal("Test")
52+
void expect(store?.capturedRequests).to.be.an("array").that.is.empty
5353
})
5454
})
5555
})
@@ -81,7 +81,7 @@ describe("CaptureContext", () => {
8181

8282
it("should not add request when not in context", () => {
8383
CaptureContext.addRequest({ method: "POST", url: "/users" })
84-
expect(CaptureContext.getCapturedRequests()).to.be.empty
84+
void expect(CaptureContext.getCapturedRequests()).to.be.empty
8585
})
8686
})
8787

@@ -122,13 +122,13 @@ describe("CaptureContext", () => {
122122
it("should do nothing when no requests exist", () => {
123123
CaptureContext.run("test", undefined, () => {
124124
CaptureContext.updateLastRequest({ body: { name: "John" } })
125-
expect(CaptureContext.getCapturedRequests()).to.be.empty
125+
void expect(CaptureContext.getCapturedRequests()).to.be.empty
126126
})
127127
})
128128

129129
it("should do nothing when not in context", () => {
130130
CaptureContext.updateLastRequest({ body: { name: "John" } })
131-
expect(CaptureContext.getCapturedRequests()).to.be.empty
131+
void expect(CaptureContext.getCapturedRequests()).to.be.empty
132132
})
133133
})
134134

@@ -138,11 +138,11 @@ describe("CaptureContext", () => {
138138
CaptureContext.addRequest({ method: "GET", url: "/users" })
139139
CaptureContext.addRequest({ method: "POST", url: "/users" })
140140

141-
expect(CaptureContext.getCapturedRequests()).to.have.lengthOf(2)
141+
void expect(CaptureContext.getCapturedRequests()).to.have.lengthOf(2)
142142

143143
CaptureContext.clear()
144144

145-
expect(CaptureContext.getCapturedRequests()).to.be.empty
145+
void expect(CaptureContext.getCapturedRequests()).to.be.empty
146146
})
147147
})
148148
})

lib/wrappers/__tests__/integration.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ describe("wrapTest integration", () => {
118118
// })
119119

120120
// NEW WAY (with wrapTest):
121-
const apiTest = wrapTest(it)
121+
// Example usage (commented out for now):
122+
// const apiTest = wrapTest(it)
122123
// apiTest('should create user', async () => {
123124
// const response = await request(app)
124125
// .post('/users')
@@ -127,7 +128,7 @@ describe("wrapTest integration", () => {
127128
// expect(response.status).toBe(201)
128129
// })
129130

130-
expect(true).to.be.true
131+
void expect(true).to.be.true
131132
})
132133
})
133134
})

lib/wrappers/__tests__/interceptedRequest.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe("interceptedRequest", () => {
5252
it("should not capture any data", async () => {
5353
await request(app).get("/users")
5454

55-
expect(CaptureContext.getCapturedRequests()).to.be.empty
55+
void expect(CaptureContext.getCapturedRequests()).to.be.empty
5656
})
5757
})
5858

0 commit comments

Comments
 (0)