Skip to content

Commit

Permalink
test(generator-helper): Attempt to reduce generatorHanlder test
Browse files Browse the repository at this point in the history
flakiness

`generatorHandler` waits for 200ms and if generator have not failed in
this time considers it a success. This is results in quite flaky
behaviour on CI. For now, attempting to overcome it by introducing the
executable that fails faster. Ideally, the error handling logic of
`generatorHandler` needs changing: it should explicictly confirm
succesful startup.
  • Loading branch information
SevInf committed Oct 19, 2022
1 parent c1afd29 commit 381e2fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('generatorHandler', () => {
jest.retryTimes(3)

const generator = new GeneratorProcess(getExecutable('invalid-executable'))
await expect(() => generator.init()).rejects.toThrow('Cannot find module')
await expect(() => generator.init()).rejects.toThrow('something terrible happened')
})

test('minimal-executable', async () => {
Expand Down
14 changes: 2 additions & 12 deletions packages/generator-helper/src/__tests__/invalid-executable
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
#!/usr/bin/env node

// let's provoke this to fail by requiring an unexisting module
require('modulethatdoesnotexist/something')

const { generatorHandler } = require('../generatorHandler')

generatorHandler({
async onGenerate() {
await new Promise((r) => {
setTimeout(r, 500)
})
},
})
console.error('something terrible happened')
process.exit(1)

0 comments on commit 381e2fb

Please sign in to comment.