Skip to content

Commit e72b073

Browse files
committed
fix tests and force color in unit tests
1 parent 1cc95c6 commit e72b073

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@
398398
"test": "npm run test:all",
399399
"test:all": "npm run pretest && c8 --no-clean -- mocha \"test/**/*.unit.test.ts\"",
400400
"test:file": "npm run pretest && c8 --no-clean -- mocha",
401-
"test:ci": "FORCE_COLOR=true npm run test:ci:unit",
402-
"test:ci:unit": "npm run pretest && mocha --forbid-only \"test/**/*.unit.test.ts\"",
401+
"test:ci": "npm run test:ci:unit",
402+
"test:ci:unit": "FORCE_COLOR=true npm run pretest && mocha --forbid-only \"test/**/*.unit.test.ts\"",
403403
"test:ci:unit:coverage": "npm run pretest && c8 --all --check-coverage --reporter=lcov --reporter=text-summary mocha --forbid-only \"test/**/*.unit.test.ts\"",
404404
"test:ci:acceptance": "npm run pretest && mocha --forbid-only \"test/**/*.acceptance.test.ts\" && node ./bin/bats-test-runner",
405405
"test:ci:integration": "npm run pretest && mocha --forbid-only \"test/**/*.integration.test.ts\"",

test/unit/analytics-telemetry/backboard-otel-client.unit.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ const isDev = process.env.IS_DEV_ENVIRONMENT === 'true'
1010
describe('backboard-otel-client', function () {
1111
let sandbox: sinon.SinonSandbox
1212
let client: BackboardOtelClient
13+
let originalTestEnv: string | undefined
1314

1415
beforeEach(function () {
1516
sandbox = sinon.createSandbox()
17+
// Temporarily enable telemetry for these tests
18+
originalTestEnv = process.env.IS_HEROKU_TEST_ENV
19+
delete process.env.IS_HEROKU_TEST_ENV
1620
client = new BackboardOtelClient()
1721
})
1822

1923
afterEach(function () {
2024
sandbox.restore()
2125
nock.cleanAll()
26+
// Restore test environment
27+
if (originalTestEnv !== undefined) {
28+
process.env.IS_HEROKU_TEST_ENV = originalTestEnv
29+
}
2230
})
2331

2432
describe('send', function () {

test/unit/analytics-telemetry/telemetry-manager.unit.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@ import {telemetryManager} from '../../../src/lib/analytics-telemetry/telemetry-m
66
const isDev = process.env.IS_DEV_ENVIRONMENT === 'true'
77

88
describe('telemetry-manager', function () {
9+
let originalTestEnv: string | undefined
10+
11+
beforeEach(function () {
12+
// Temporarily enable telemetry for these tests
13+
originalTestEnv = process.env.IS_HEROKU_TEST_ENV
14+
delete process.env.IS_HEROKU_TEST_ENV
15+
})
16+
917
afterEach(function () {
1018
nock.cleanAll()
19+
// Restore test environment
20+
if (originalTestEnv !== undefined) {
21+
process.env.IS_HEROKU_TEST_ENV = originalTestEnv
22+
}
1123
})
1224

1325
describe('setupTelemetry', function () {

test/unit/lib/spaces/format.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('spaces/format', function () {
2929
expect(hostStatus('under-assessment')).to.eq('\u001B[38;5;43munder-assessment\u001B[39m')
3030
expect(hostStatus('permanent-failure')).to.eq('\u001B[38;2;255;135;135mpermanent-failure\u001B[39m')
3131
expect(hostStatus('released-permanent-failure')).to.eq('\u001B[38;2;255;135;135mreleased-permanent-failure\u001B[39m')
32-
expect(hostStatus('released')).to.eq('\u001B[90mreleased\u001B[39m')
32+
expect(hostStatus('released')).to.eq('\u001B[38;5;248mreleased\u001B[39m')
3333
expect(hostStatus('foo')).to.eq('foo')
3434
})
3535
})

0 commit comments

Comments
 (0)