2.2.3 Issues I'm having with the first two test examples

Hi there, really enjoying the course so far but I’ve gotten a bit stuck with the first two examples.

  1. Building a Basic Unit Component Check

The tests for this one appear to be running fine but my linter doesn’t like this line of code and I’ve had to get it to ignore it (using // eslint-disable-next-line testing-library/prefer-screen-queries. I was wondering what this meant/ why my IDE sees it as incorrect as I don’t understand it.

await findByText('Project 1');

Getting Stuck in With Code - UI Layer

I’m having a bit more problems with this in terms of the code looks sound to me, please let me know if i’m missing anything…

const { expect, browser, $ } = require('@wdio/globals')

describe('My Login application', () => {

   it('should login with valid credentials', async () => {
       await browser.url(`http://localhost:3000/#/login`)

       await $('input[name="email"]').setValue('admin@test.com')
       await $('input[name="password"]').setValue('password123')
       await $('button').click()

       const element = await $('.card-title')
       await expect(element).toHaveText('Projects')


From what I can see the capabilities part of the wdio.conf.js file looks as expected, but when i run the command npx wdio run ./wdio.conf.js --spec login.e2e.js it isn’t happy.


Replace the destructuring assignment with the screen.findByTest method:

const findByTest = await
screen.findByTest(‘Projct 1’);

This change ensure that you are using the preferred method for quering element in your tests.

Additionally, update the WebDriverIO configuration to use a different version of Chromedriver that is available for download. Ensure that the specified version is compatible with your WebDriverIO version and the browser version you intend to use for testing.

Also, review the test script (Login.e2e.js) to ensure it is correctly written and does not contain any syntax errors and logical issues.

1 Like