Skip to content

Commit

Permalink
Merge pull request #613 from appsignal/fix-client-start-tests
Browse files Browse the repository at this point in the history
Fix tests on client start
  • Loading branch information
unflxw authored Feb 14, 2022
2 parents ecb8bed + e45ffb4 commit 6f2f1f7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/nodejs/src/__tests__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,23 @@ describe("BaseClient", () => {
expect(BaseClient.config).toEqual(client.config)
})

it("does not start the client if config is not valid", () => {
process.env["APPSIGNAL_PUSH_API_KEY"] = undefined
const startSpy = jest.spyOn(client.extension, "start")
client = new BaseClient({ name, enableMinutelyProbes: false })
it("does not start the client if the config is not valid", () => {
const startSpy = jest.spyOn(Extension.prototype, "start")
// config does not include a push API key
client = new BaseClient({ name, active: true })
expect(startSpy).not.toHaveBeenCalled()
})

it("does not start the client if the active option is false", () => {
const startSpy = jest.spyOn(Extension.prototype, "start")
client = new BaseClient(DEFAULT_OPTS)
expect(startSpy).not.toHaveBeenCalled()
})

it("starts the client when the active option is true", () => {
const startSpy = jest.spyOn(client.extension, "start")
const startSpy = jest.spyOn(Extension.prototype, "start")
client = new BaseClient({ ...DEFAULT_OPTS, active: true })
expect(startSpy).not.toHaveBeenCalled()
expect(startSpy).toHaveBeenCalled()
})

it("returns a NoopTracer if the agent isn't started", () => {
Expand Down

0 comments on commit 6f2f1f7

Please sign in to comment.