GitHub Actions: Continuous Integration: Step 5 Fix the Test

Hello. I fixed the test but keep getting the error below from the test/game.test.js file. I tried removing done from the file and still got an error. I reverted back

Test functions cannot both take a ‘done’ callback and return something. Either use a ‘done’ callback, or return a promise.

Hi, I faced the same issue and found a solution. All you have to do to fix it is edit the game.test.js file in the test folder and replace async(done) in

describe('App', () => {
  it('Contains the compiled JavaScript', async(done) => {
    fs.readFile('./public/main.js', 'utf8', (err, data) => {
      expect(err).toBe(null)
      expect(data).toMatchSnapshot()
      done()
    })
  })
})

with done =>
like this

describe('App', () => {
  it('Contains the compiled JavaScript', done => {
    fs.readFile('./public/main.js', 'utf8', (err, data) => {
      expect(err).toBe(null)
      expect(data).toMatchSnapshot()
      done()
    })
  })
})

That should make all the tests pass and you will be able to proceed to the next steps.
I think it might be a bug or maybe some decrepitated implementation of jest. I don’t know much about Jest, so I cant say for sure.

But since this course about CI and not Jest, this simple fix would help you proceed.

Github Team, please fix this.

Thank You.

1 Like

Thank you! Finally got to the next step. I don’t know much about Jest. I appreciate the further explanation so I can try to see what I can learn.

1 Like