DEV Community

Amazing
Amazing

Posted on

Lab 10: CI testing and contribute test to other SSG project

Last week, I forgot to update my CONTRIBUTING.md and since the lab this week require to develop a CI testing, that would be perfect so I do not have to create any dummy change to test my CI

Setting and running CI test

Thanks to the lecture and well explainations. It was really easy for me to set up my .github/workflows/node.js.yml. I choose to follow the default setting where I got the CI test run everytime someone push it to the main branch, using online host to run the project on the latest ubuntu version and test it with the specified node version

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
...

build:
    runs-on: ubuntu-latest
...

node-version: [12.x, 14.x, 16.x]

Enter fullscreen mode Exit fullscreen mode

You can check out the status and my PR-20.

Contribute to my colleague project

This week, I choose Luigi octo to work on. He has 14 stars for his project so it a bit pressure but I will take it. You can check out my PR-20

I see that Luigi did not have unit test for the ./bin/app.js so I step in and created one. I make options from and object and turn to a callable function so as I can parse different arguments through the options blueprint and see if it work as it should be.

const options = (args = process.argv.slice(2)) =>
  yargs(args)
    .usage(`Usage: -i <path>`)
    .option(`input`, {
      alias: `i`,
      describe: `Path to file`,
      type: `string`,
      demandOption: true,
    })
...
Enter fullscreen mode Exit fullscreen mode

But after I automated test for app.js I keep received this error log

●  Cannot log after tests are done. Did you forget to wait for something async in your test?
    Attempted to log "This is main Error
    Error: ENOENT: no such file or directory, lstat 'C:\Users\Administrator\Desktop\repo\octo\undefined'".

      121 |       if (path.includes(".txt")) {
      122 |         return textToHTML(path, lang).then((data) => {
      126 |

      at console.log (node_modules/@jest/console/build/BufferedConsole.js:199:10)
      at bin/fileFunctions.js:123:29
Enter fullscreen mode Exit fullscreen mode

I spend quite amount of time on it and asking my friend Duke. We both regconize that it happen because in ./bin/app.js also make a call to the options function by using the fileFunctions object from another module so I just need to refactor that part of the code where it was calling the options function to another file and all the test ran smoothly. After all, I did feel happy that I was be able to contribute to a good project and still waiting for Luigi to get back to me on my changes.

Discussion (0)