0

I keep getting an error when running a basic sample with Nightwatch.js + Testing Library:

[Ecosia Search With TL] Test Suite
==================================
ℹ Connected to localhost on port 9515 (1077ms).
  Using: chrome (87.0.4280.66) on Mac OS X platform.

Running:  Demo test ecosia.org

matcher.test is not a function

FAILED: 1 errors (935ms)
_________________________________________________

TEST FAILURE: 1 error during execution; 0 tests failed, 0 passed (2.779s)

 ✖ ecosiaSearchWithTL
 – Demo test ecosia.org (935ms)

  Error: [object Object]
       at processTicksAndRejections (internal/process/task_queues.js:97:5)


npm ERR! Test failed.  See above for more details.

This is my only test:

const { getQueriesFrom } = require('@testing-library/nightwatch')

module.exports = {

  async beforeEach(browser) {
    await browser.url('https://www.ecosia.org/')
  },

  async 'Demo test ecosia.org'(browser) {
    const { getByRole } = getQueriesFrom(browser)

    const searchBox = await getByRole('searchbox', { name: /search form/i })
    browser.setValue(searchBox, 'nightwatch')
    const submit = await getByRole('button', { name: /submit/i })
    browser.click(submit)
    browser.end()
  }
}

My nightwatch.conf.js:

module.exports = {
    src_folders: ['tests'],
  
    webdriver: {
      start_process: true,
      port: 9515,
      server_path: "node_modules/.bin/chromedriver",
    },
  
    test_settings: {
      default: {
        desiredCapabilities : {
            browserName: "chrome"
        }
      }
    }
  };

Any idea why I keep getting that error? It works flawlessly without Testing Library.

Luís Soares
  • 5,726
  • 4
  • 39
  • 66
  • 1
    Per the linked docs, *"Note, in NWTL, all queries must be `await`ed."* You **don't** await your queries, so you're passing promises not locators - presumably the latter do have a `test` method, but promises don't. – jonrsharpe Nov 17 '20 at 23:17
  • you're totally right. with all the experiments I forgot that. I edited the question though with the fix and the updated error output. – Luís Soares Nov 17 '20 at 23:21
  • I'm trying to get this up and running and I'm getting the same error but even using the code above. Really want to use RTL with nightwatch but just doesn't seem to work and have no idea why. – Stefan Burt Dec 16 '21 at 08:04

0 Answers0