FCTA_JS_Activity 2.4.2: Failing pipeline tests in Github Actions

Hi folks,
I’m trying to run the pipeline tests in Github Actions following the steps for Activity in module 2.4.2, however the unit checks are failing and I can’t able to proceed further. I attempted to install the dependencies and fix the vulnerabilities issues from the errors I get to see from the job results but I’m not having much luck. Appreciate some help here :slight_smile:

Attaching the screenshot of the error below to help with debugging.

2 Likes

Hey,
I’d guess it’s a mismatch of versions of some libraries between package.json and package-lock.json.
Did you try already to:

  • go to the project directory on the local computer
  • execute from a terminal the command: npm install
  • commit and push the package-lock.json changes to git
  • retry the pipeline execution

Or, as sometimes it’s a more complex issue:

  • go to the project directory on the local computer
  • delete the package-lock.json file
  • execute from a terminal the command: npm install
  • commit and push the package-lock.json changes to git
  • retry the pipeline execution
4 Likes

Thanks @ipstefan. Unit tests are passing in the pipeline job. When E2E tests are executed I’m getting BABEL_PARSE_ERROR in the wdio.conf.js file. Can you advise what needs to be done in this case?

2 Likes

Hi,
Your error seems to be coming from this library file:

There might be a declared and used a path that doesn’t exist.
I’d go through the files and check the variables that should contain a path and recheck that the path matches the file that its intended to import.

3 Likes

@vidhyalakshmi this can happen due to auto complete picking the wrong library.

You will likely find fs imported at the top of one of the
files you have either made or updated.

If you still can’t get it working then please share your repo and I can take a look.

3 Likes

Thank you @ipstefan and @a_mcanirn for your inputs. I could only see wdio.conf.js file in my repo and I’m not able to locate import fs being used in any of the files.

I’ve shared my repository link below, hope it helps to debug the issue more effectively.

1 Like

Looking at the latest failing build it appears that your wdio.conf.js file is not formatted correctly. Likely it’s missing a bracket or a comma. That’s why Babel is failing because it can’t parse the file.

Would someone else like to share an example wdio.conf.js to show how it should look when correctly formattted.

1 Like

Yep you are right @mwinteringham There is some extra bracket at the end of the wdio.conf.js which I’m not sure how to resolve it. Thanks for the headsup :+1:

1 Like

Mark might be right there.
Line 58 in wdio.conf.js looks like it has an extra } which can be removed.
I don’t recommend deleting the one at the end as you have extra settings you want to take over in the export.config

1 Like

Removing the bracket in Line 59 helped me to move to the next step. However this time got a new error stating that the Spec reporter has failed to install. I installed the plugin and re-ran the job and it failed again with a new error.

2024-07-01T10:52:30.345Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't initialise "@wdio/spec-reporter".

[0-0] Error [ERR_REQUIRE_ESM]: require() of ES Module D:\a\mot-cert-support-app-js\mot-cert-support-app-js\node_modules\@wdio\spec-reporter\build\index.js from D:\a\mot-cert-support-app-js\mot-cert-support-app-js\node_modules\@wdio\runner\node_modules\@wdio\utils\build\utils.js not supported.

[0-0] Instead change the require of index.js in D:\a\mot-cert-support-app-js\mot-cert-support-app-js\node_modules\@wdio\runner\node_modules\@wdio\utils\build\utils.js to a dynamic import() which is available in all CommonJS modules.
1 Like

Looks like wdio.config.js has spec set as the reporter but you don’t have it as a dependency in package.json .

Install it by using - npm install @wdio/spec-reporter --save-dev
Link to docs - Spec Reporter | WebdriverIO

I checked and this looks to fix things locally (however, seeing unrelated issue with test\specs\test.e2e.js - might be better to update/delete this).

2 Likes

Finally out of 2 tests one is passing (\test\specs\test.e2e.js) and the other is failing (\test\specs\Login.e2e.js). From the error I could see that the selector element .card-title is not findable when the tests are run, but its passing when I run locally.

I changed the code to look like below, but that didn’t work.
await expect($('.card-title')).toHaveText(expect.stringContaining('Projects'))

1 Like

Try increase the actions sleep period
up to something like 30s - mot-cert-support-app-js/.github/workflows/build_test_react.yml at 822c37800320d5b925b14f45b4cd3833b2bd0069 · vidhu09/mot-cert-support-app-js · GitHub

2 Likes

Oh, the command that should not exist in the first place.
It should be banned for new automators as it’s quite easy to overuse instead of thinking of how to make stable locators function and reliable scenarios.

1 Like

Finally got my first pipeline job with passing tests :tada:
@a_mcanirn Thanks for the suggestion around increasing the sleep time. The tests were failing when I set to 30s but then I randomly increased to 100s and it worked magically! :rocket:

Also thanks to everyone for providing your inputs in helping me to resolve the issue.
Successful on commit #23 :muscle: Patience really matters :smile:

1 Like