Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question:Error in sample step-by-step #36

Open
vrathnayake opened this issue Feb 24, 2020 · 7 comments
Open

Question:Error in sample step-by-step #36

vrathnayake opened this issue Feb 24, 2020 · 7 comments

Comments

@vrathnayake
Copy link

vrathnayake commented Feb 24, 2020

Followed the step-by-step tutorial
https://github.com/garris/ember-backstop-tutorial/
added "await backstop(assert);" to the last four tests and the tests failed as mentioned. Then I approved the screenshots(backstop-approve). BackstopJs Report shows all passing. But the four tests fail when run with following error;

  1. Promise rejected during "should link to contact information": Unexpected end of JSON input
    Source: SyntaxError: Unexpected end of JSON input
    at parse ()
@vrathnayake vrathnayake changed the title Error in sample step-by-step Question:Error in sample step-by-step Feb 25, 2020
@garris
Copy link
Owner

garris commented Feb 25, 2020

Hi @vrathnayake, What version of ember-backstop & backstopjs are you using?

@vrathnayake
Copy link
Author

ember-backstop 1.2.1
backstopjs 4.3.2

@shankarsridhar
Copy link
Contributor

@vrathnayake Can you share a link to a sample repo that reproduces this problem ?

@garris
Copy link
Owner

garris commented Mar 4, 2020

@shankarsridhar looks like she was following this... https://github.com/garris/ember-backstop/issues/tutorial

Does that work for you?

@shankarsridhar
Copy link
Contributor

@shankarsridhar looks like she was following this... https://github.com/garris/ember-backstop/issues/tutorial

Does that work for you?

Yes it does. I was able to generate screenshots, approve them to baseline, and then make the failing backstop tests pass again.

On a separate note, maybe we should upgrade the ember-backstop dependency to latest.

@vrathnayake
Here is the list-rentals-test.js test file after I added the assertions:

import Service from '@ember/service';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import backstop from 'ember-backstop/test-support/backstop';
import { resolve } from 'rsvp';
import {
  click,
  currentURL,
  visit,
  fillIn,
  triggerKeyEvent
} from '@ember/test-helpers'

let StubMapsService = Service.extend({
  getMapElement() {
    return resolve(document.createElement('div'));
  }
});

module('Acceptance | list rentals', function(hooks) {
  setupApplicationTest(hooks);
  setupMirage(hooks);

  hooks.beforeEach(function() {
    this.owner.register('service:map-element', StubMapsService);
  });

  test('should redirect to rentals route', async function(assert) {
    await visit('/');
    assert.equal(currentURL(), '/rentals', 'should redirect automatically');
  });

  test('should link to information about the company', async function(assert) {
    await visit('/');
    await click(".menu-about");
    assert.equal(currentURL(), '/about', 'should navigate to about');
  });

  test('should link to contact information', async function(assert) {
    await visit('/');
    await backstop(assert);
    await click(".menu-contact");
    assert.equal(currentURL(), '/contact', 'should navigate to contact');
  });

  test('should list available rentals', async function(assert) {
    await visit('/');
    await backstop(assert);
    assert.equal(this.element.querySelectorAll('.results .listing').length, 3, 'should display 3 listings');
  });

  test('should filter the list of rentals by city', async function(assert) {
    await visit('/');
    await backstop(assert);
    await fillIn('.list-filter input', 'seattle');
    await triggerKeyEvent('.list-filter input', 'keyup', 69);
    assert.ok(this.element.querySelectorAll('.results .listing').length, 1, 'should display 1 listing');
    assert.ok(this.element.querySelector('.listing .location').textContent.includes('Seattle'), 'should contain 1 listing with location Seattle');
  });

  test('should show details for a specific rental', async function(assert) {
    await visit('/rentals');
    await backstop(assert);
    await click(".grand-old-mansion");
    assert.equal(currentURL(), '/rentals/grand-old-mansion', "should navigate to show route");
    assert.ok(this.element.querySelector('.show-listing h2').textContent.includes("Grand Old Mansion"), 'should list rental title');
    assert.ok(this.element.querySelector('.show-listing .description'), 'should list a description of the property');
  });
});

@shankarsridhar
Copy link
Contributor

Followed the step-by-step tutorial
https://github.com/garris/ember-backstop-tutorial/

On a side note,
Looks like https://github.com/garris/ember-backstop-tutorial/ is linking to something else other than https://github.com/garris/ember-backstop-tutorial/ which is misleading 👀

@Neeraj222
Copy link

Hi @shankarsridhar, I am facing the same issue as @vrathnayake. Has there been a fix for this problem ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants