Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.2] - 2025-07-16

### Fixed

- Error when trying to remove secrets from console logs that had non-string parameters.

## [0.2.1] - 2025-05-15

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-environment-airtable-script",
"version": "0.2.1",
"version": "0.2.2",
"description": "A jest environment for testing Airtable scripts in extensions and automations",
"license": "Apache-2.0",
"author": "",
Expand Down
5 changes: 4 additions & 1 deletion src/environment/console-aggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ const consoleAggregator = (): ConsoleAggregator => {
return message
}
return secretValues.reduce(
(acc, value) => acc.replace(value, SECRET_VALUE_REDACTED),
(acc, value) =>
typeof acc === 'string'
? acc.replace(value, SECRET_VALUE_REDACTED)
: acc,
message
)
}
Expand Down
48 changes: 47 additions & 1 deletion test/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,58 @@ describe('Input', () => {
},
},
})
console.log(results)
expect(results.console[0]).toEqual({
message: SECRET_VALUE_REDACTED,
type: 'log',
})
})

it('masks a partial secret value when console.logged', async () => {
const results = await runAirtableScript({
script: `
const config = input.secret('test-key')
console.log(\`hello, \${config}\`)
`,
base: randomRecords,
inAutomation: true,
mockInput: {
secret: (secretKey: string) => {
if (secretKey === 'test-key') {
return 'test-secret-value'
}
return null
},
},
})
expect(results.console[0]).toEqual({
message: `hello, ${SECRET_VALUE_REDACTED}`,
type: 'log',
})
})

it('does not try to mask a secret in a non-string item is logged', async () => {
const results = await runAirtableScript({
script: `
const config = input.secret('test-key')
console.log(1)
`,
base: randomRecords,
inAutomation: true,
mockInput: {
secret: (secretKey: string) => {
if (secretKey === 'test-key') {
return 'test-secret-value'
}
return null
},
},
})

expect(results.console[0]).toEqual({
message: 1,
type: 'log',
})
})
})
describe('extension script', () => {
it('passes a text item', async () => {
Expand Down