Github-actions-for-ci stuck on step 13 again

I have a problem with steep 13.
Even when I copy the solution my test are not executed properly.
FAIL test/game.test.js

2020-09-14T07:40:41.2614710Z FAIL test/game.test.js
2020-09-14T07:40:41.2622697Z App
2020-09-14T07:40:41.2657990Z ✕ Contains the compiled JavaScript (7 ms)
2020-09-14T07:40:41.2659393Z Game
2020-09-14T07:40:41.2660493Z Game
2020-09-14T07:40:41.2661833Z ✓ Initializes with two players (1 ms)
2020-09-14T07:40:41.2663327Z ✓ Initializes with an empty board
2020-09-14T07:40:41.2664777Z ✓ Starts the game with a random player (1 ms)
2020-09-14T07:40:41.2665829Z turn
2020-09-14T07:40:41.2667167Z ✓ Inserts an ‘X’ into the top center
2020-09-14T07:40:41.2669469Z ✓ Inserts an ‘X’ into the top left (1 ms)
2020-09-14T07:40:41.2670492Z nextPlayer
2020-09-14T07:40:41.2671886Z ✓ Sets the current player to be whoever it is not (1 ms)
2020-09-14T07:40:41.2673172Z hasWinner
2020-09-14T07:40:41.2674306Z ✓ Wins if any row is filled
2020-09-14T07:40:41.2675599Z ✓ Wins if any column is filled (1 ms)
2020-09-14T07:40:41.2677161Z ✓ Wins if down-left diagonal is filled (1 ms)
2020-09-14T07:40:41.2677860Z ✓ Wins if up-right diagonal is filled (1 ms)
2020-09-14T07:40:41.2678705Z ● App › Contains the compiled JavaScript
2020-09-14T07:40:41.2681392Z expect(received).toBe(expected) // equality
2020-09-14T07:40:41.2682050Z Expected: null
2020-09-14T07:40:41.2682898Z Received: [Error: ENOENT: no such file or directory, open ‘./public/main.js’]
2020-09-14T07:40:41.2683941Z 5 | it(‘Contains the compiled JavaScript’, async (done) => {
2020-09-14T07:40:41.2685123Z 6 | fs.readFile(’./public/main.js’, ‘utf8’, (err, data) => {
2020-09-14T07:40:41.2685579Z > 7 | expect(err).toBe(null)
2020-09-14T07:40:41.2685885Z | ^
2020-09-14T07:40:41.2686267Z 8 | expect(data).toMatchSnapshot()
2020-09-14T07:40:41.2686637Z 9 | done()
2020-09-14T07:40:41.2686887Z 10 | })
2020-09-14T07:40:41.2687582Z at ReadFileContext.callback (test/game.test.js:7:19)
2020-09-14T07:40:41.2688631Z Test Suites: 1 failed, 1 total

Previous steeps ware successful.
Any ideas what could be broken?

Thanks in advance!


Sorry to see you are having problems with the course. I took a look into your repo, and it seems as though you have done everything correctly! So :+1: to you!

The problem is with the ephemeral nature of GitHub Actions. Your workflow has two different jobs, one named build and one named test. The do what you would expect them to do, build and test your application.

The problem is build and test do not share an environment, and quite honestly they no nothing about one another. So when build compiles the JS for the app, then finishes the job, it deletes the compiled JS :flushed: . Then when test tries to run its tests one of them fails because it cannot find the compiled JS!

A quick fix that should work for you, while we get a more realistic fix in place would be to build the application in the test job again. So inside of the test job you have a run block like this:

    - name: npm install, and test
      run: |
        npm install
        npm test
        CI: true

Edit this block in the workflow file to look like this and everything should work:

    - name: npm install, and test
      run: |
        npm install
        npm run build
        npm test
        CI: true

Thank you very much! It helped!