mardi 20 février 2018

Emberjs 3.0 tests: how to select link by content

The following is a test that apparently works in Ember.js 2.15, but seem not to work in version 3.0: Failed to execute 'querySelector' on 'Element': 'a:contains('Contact')' is not a valid selector.

import { module, test } from 'qunit';
import { visit, currentURL, click } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';

module('Acceptance | list rentals', function(hooks) {
  setupApplicationTest(hooks);
    test('should show link to contact', async function(assert){
            await visit('/');
            await click("a:contains('Contact')");
            assert.equal(currentURL(),'/contact','should navigate to contact');
    });
});

How to do this in Ember.js 3.0?

I couldn't find it in the online Ember guides. The tutorials seem to refer thus to previous versions.

PS:The application's template file contains

 
    Contact
  




Aucun commentaire:

Enregistrer un commentaire