Open filmaj opened 1 year ago
Was trying to add a feature and was writing tests and saw some very weird behaviour on node v20.2.0.
In /tests/index.ts.ts, in the beforeEach, if you add this console.log line at the end of the setup function:
/tests/index.ts.ts
beforeEach
console.log
beforeEach(() => { nock.cleanAll() tools = generateToolkit() delete process.env.INPUT_SETUP delete process.env.INPUT_TAG_NAME console.log(tools.context.payload) })
... you can see that the context.payload state that is modified in certain tests in index.test.ts (like setting draft or prelease) leaks across tests. Here's the output from npm test (see last two logs):
context.payload
index.test.ts
draft
prelease
npm test
● Console console.log { release: { draft: false, prerelease: false, tag_name: 'v1.0.0' } } at Object.<anonymous> (tests/index.test.ts:14:13) console.log { release: { draft: false, prerelease: false, tag_name: 'v1.0.0' } } at Object.<anonymous> (tests/index.test.ts:14:13) console.log { release: { draft: false, prerelease: false, tag_name: 'v1.0.0' } } at Object.<anonymous> (tests/index.test.ts:14:13) console.log { release: { draft: true, prerelease: false, tag_name: 'v1.0.0' } } at Object.<anonymous> (tests/index.test.ts:14:13) console.log { release: { draft: true, prerelease: true, tag_name: 'v1.0.0' } } at Object.<anonymous> (tests/index.test.ts:14:13)
Was trying to add a feature and was writing tests and saw some very weird behaviour on node v20.2.0.
In
/tests/index.ts.ts
, in thebeforeEach
, if you add thisconsole.log
line at the end of the setup function:... you can see that the
context.payload
state that is modified in certain tests inindex.test.ts
(like settingdraft
orprelease
) leaks across tests. Here's the output fromnpm test
(see last two logs):