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

Jasmine ReferenceError: "Map" is not defined #269

Closed
Geoffrey0 opened this issue Mar 25, 2015 · 3 comments
Closed

Jasmine ReferenceError: "Map" is not defined #269

Geoffrey0 opened this issue Mar 25, 2015 · 3 comments
Labels
stale Issues with no activity

Comments

@Geoffrey0
Copy link

Hello,

I just started writing jasmine tests for a backlog of code in our project.
We frequently use the Map object as in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

However when doing a simple jasmine test it fails.

describe('MapTest', function () {
it("tests if map is defined", function () {
var map = new Map();
expect(map).toBeDefined();
});
});
Output:
1.) MapTest it tests if map is defined <<< FAILURE!
* ReferenceError: "Map" is not defined.

I've tested this in version 1.3.1.3 and 1.3.1.5.
When I use the bdd option and open the chrome browser the tests pass.
Output:
MapTest
tests if map is defined (green)

Therefore I expect that something is wrong with our configuration. However, I can not find the issue.
Any help is greatly appreciated!

@jhwohlgemuth
Copy link

I was just passing through and I thought I would try helping out with this question:

Prior to version 2, this plugin uses HtmlUnit as the browser environment in which the tests are run. Under the hood, HtmlUnit uses Rhino which is a really old (released in 1998!) browser environment implemented entirely in java...as far as I know, Rhino is no longer actively supported.

In any case, starting with version 2.0 jasmine-maven-plugin uses PhantomJS by default. PhantomJS is newer than Rhino with much better JavaScript support. However even PhantomJS does not implement Map. The Rhino documentation is sparse to say the least, but I think it is safe to say it has support equal to or less than that of PhantomJS.

Bottom Line: Map is an ES6 feature that is not supported by HtmlUnit or PhantomJS and therefore cannot be used for headless testing with jasmine-maven-plugin (via the jasmine:test goal).

Note: Firefox does support Map which is why your tests pass using the jasmine:bdd goal

This issue has irked me for a while since a few devs on my team want to use ES6, but can't because of our reliance on CI servers running tests in a headless environment... Sadly, PhantomJS v2.5 was going to have complete ES6 support but the project has recently lost its primary maintainer and I am skeptical v2.5 will ever see a "production" release...

@github-actions
Copy link

github-actions bot commented Feb 4, 2021

This issue has been marked as stale because it has not been updated in 60 days. Please add a comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale Issues with no activity label Feb 4, 2021
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no updates.

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

No branches or pull requests

2 participants