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

Arguments variable in functions is empty when called from mocha it(). #105

Closed
davidkudera opened this issue Nov 10, 2013 · 1 comment
Closed

Comments

@davidkudera
Copy link

Example:

var test = function(arg) {
  console.log(arguments);
};

test('first');

describe('tests', function() {
  test('second');

  it('should do something', function() {
    test('third');
  });
});

Console:

Arguments[1] {0: 'first'}
Arguments[1] {0: 'second'}
{}

In browser everything works just fine.

@nathanboktae
Copy link
Owner

That's because mocha-phantomjs has to marshal your console.log call across to phantomjs, another javascript environment, and arguments isn't an instance of Array, but array like.

try:

console.log(Array.prototype.slice.call(arguments));

Also see #104 - same core root cause.

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

2 participants