Skip to content

Commit d401375

Browse files
committed
fix: isolate tests from CI environment variables
Tests were failing on GitHub Actions because GITHUB_ACTIONS env var triggers CI metadata appending to commit messages. Tests now explicitly clear CI environment variables to ensure consistent behavior.
1 parent dc78d0d commit d401375

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/parameter-tests/builder-integration.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,31 @@ import * as engine from '../engine/engine';
8888

8989
describe('Angular Builder Integration Tests', () => {
9090
let context: BuilderContext;
91+
let originalEnv: NodeJS.ProcessEnv;
9192

9293
const PROJECT = 'test-project';
9394
const BUILD_TARGET: BuildTarget = {
9495
name: `${PROJECT}:build:production`
9596
};
9697

9798
beforeEach(() => {
99+
// Save and clear CI environment variables to ensure consistent test behavior
100+
originalEnv = { ...process.env };
101+
delete process.env.TRAVIS;
102+
delete process.env.CIRCLECI;
103+
delete process.env.GITHUB_ACTIONS;
104+
98105
// Clean up any previous monkeypatch so each test starts fresh
99106
cleanupMonkeypatch();
100107
capturedPublishOptions = null;
101108
context = createMockContext();
102109
});
103110

111+
afterEach(() => {
112+
// Restore original environment
113+
process.env = originalEnv;
114+
});
115+
104116
afterAll(() => {
105117
// Clean up monkeypatch after all tests
106118
cleanupMonkeypatch();

src/parameter-tests/cli-e2e.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ function runCli(args: string): string {
3434
}
3535

3636
const program = path.resolve(__dirname, '../dist/angular-cli-ghpages');
37-
return execSync(`node ${program} --dry-run ${args}`).toString();
37+
// Clear CI environment variables to ensure consistent test behavior across environments
38+
const env = { ...process.env };
39+
delete env.TRAVIS;
40+
delete env.CIRCLECI;
41+
delete env.GITHUB_ACTIONS;
42+
43+
return execSync(`node ${program} --dry-run ${args}`, { env }).toString();
3844
}
3945

4046
function parseJsonFromCliOutput(output: string): DryRunOutput {

0 commit comments

Comments
 (0)