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

AfterEach hook when using --testcase argument #574

Closed
tomyf opened this issue Jul 22, 2015 · 1 comment
Closed

AfterEach hook when using --testcase argument #574

tomyf opened this issue Jul 22, 2015 · 1 comment
Assignees
Labels

Comments

@tomyf
Copy link

tomyf commented Jul 22, 2015

Hi,
I tried to use the 'afterEach' hook in a test suite, but when using the --testcase argument, it is not invoked. Console output is provided below a simple test case.

Code here :

module.exports = {
  before : function(browser) {
    browser.maximizeWindow();
    browser.perform(function() {
      console.log('before');
    });
  },

  after : function(browser) {
    browser.perform(function() {
      console.log('after');
    });
    browser.end();
  },

  beforeEach : function(browser) {
    browser.perform(function() {
      console.log('beforeEach');
    });
  },

  afterEach : function(browser, done) {
    browser.perform(function() {
      console.log('afterEach');
      done();
    });
  },

  'testcase1' : function(browser) {
    browser.perform(function() {
      console.log('testcase1');
      browser.assert.ok(true);
    });
  },

  'testcase2' : function(browser) {
    browser.perform(function() {
      console.log('testcase2');
      browser.assert.ok(true);
    });
  }
};

When using nightwatch --test ./tests/test.js, the output is as expected :

Starting selenium server... started - PID:  17224

[Test] Test Suite
=================

Running:  testcase1
before
beforeEach
testcase1
 ✔ Passed [ok]: true ok
afterEach

OK. 1 assertions passed. (2.519s)

Running:  testcase2
beforeEach
testcase2
 ✔ Passed [ok]: true ok
afterEach

OK. 1 assertions passed. (2ms)
after

OK. 2 total assertions passed. (3.734s)

But, when specifying the testcase to run, ie. nightwatch --test ./tests/test.js --testcase 'testcase1', the afterEach method is not invoked :

Starting selenium server... started - PID:  11836

[Test] Test Suite
=================

Running:  testcase1
before
beforeEach
testcase1
 ✔ Passed [ok]: true ok

OK. 1 assertions passed. (2.533s)
after

Is there something I am missing ?

@sknopf sknopf added the bug label Jul 24, 2015
@sknopf sknopf self-assigned this Jul 24, 2015
@sknopf
Copy link
Collaborator

sknopf commented Jul 25, 2015

I have a fix here

@sknopf sknopf closed this as completed in 9d81aca Aug 11, 2015
beatfactor added a commit that referenced this issue Aug 11, 2015
…th-testcase-opt

Fix #574 should run afterEach with testcase cli option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants