CraftAcademy / CraftOverflow

7 stars 3 forks source link

ELIFECYCLE error when I run npm run test... HELP! #48

Open lucamarial opened 5 years ago

lucamarial commented 5 years ago

Problem

I have a problem running my tests for the rock paper scissors challenge. I installed the e2e training wheels, load my js code inside the html body in script tags, run npm in the terminal and the tests passed. Without making any changes, the next day I run the tests again and it showes me an ELIFECYCLE error and that the document is not defined.

Feature test

require('../spec.helper');

describe('User can make a choice between Rock, Paper or Scissors', () => {
  before(async () => {
    await browser.init()
    await browser.visitPage('http://localhost:8080/')
  });

  beforeEach(async () => {
    await browser.page.reload();
  });

  after(() => {
    browser.close();
  });

  it('renders the Rock button', async () => {
    let button = await browser.getContent("[Id='r']")
    expect(button).to.eql('Rock');
  });

  it('renders the Paper button', async () => {
    let button = await browser.getContent("[Id='p']")
    expect(button).to.eql('Paper');
  });

  it('renders the Scissors button', async () => {
    let button = await browser.getContent("[Id='s']")
    expect(button).to.eql('Scissors');
  });
});

Specs

require('../spec.helper')

describe('Rock-Paper-Scissor Game', () => {

    describe('smoke tests', () => {
        it('should exist', () => {
            expect(RockPaperScissors).to.exist;
        })

        it('should be a function', () => {
            expect(RockPaperScissors).to.be.a('function');
        })
    })
})

Spec-helper

const chai = require('chai');
const BrowserHelpers = require('e2e_training_wheels')
global.browser = new BrowserHelpers()
global.expect = chai.expect;
global.RockPaperScissors = require('./src/js/rockpaperscissors')

Screenshots

Screenshot from 2019-10-01 12-36-32

Screenshot from 2019-10-01 12-36-59

How did you try to solve the problem?

Usually the problem is solved when I change node version to the latest version, but not this time. I also tried to remove the node_modules and reinstall it.

github repo

tochman commented 5 years ago

Hi, there is not enough info here. the error relates to document not being defined. Please provide more context. What does the test look like? When is the js code being loaded on the page? etc.