Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't assume exports is defined when window is undefined #257

Merged
merged 1 commit into from

2 participants

@kevinoid

The current code makes the assumption that if window is undefined it is
being run in an environment which supports the CommonJS Modules spec.
This is not the case when Jasmine is being run in rhino or SpiderMonkey
(smjs) without EnvJS (e.g. using either http://stackoverflow.com/a/5767884 or https://gist.github.com/3146420 to provide setTimeout).

The attached commit fixes the issue by checking that exports is an object.

@kevinoid kevinoid Don't assume exports is defined when window is undefined
The current code makes the assumption that if window is undefined it is
being run in an environment which supports the CommonJS Modules spec.
This is not the case when Jasmine is being run in rhino or SpiderMonkey
(smjs) without EnvJS.

The fix is simply to check that exports is an object.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
442f3bf
@infews infews merged commit 39a55d8 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 19, 2012
  1. @kevinoid

    Don't assume exports is defined when window is undefined

    kevinoid authored
    The current code makes the assumption that if window is undefined it is
    being run in an environment which supports the CommonJS Modules spec.
    This is not the case when Jasmine is being run in rhino or SpiderMonkey
    (smjs) without EnvJS.
    
    The fix is simply to check that exports is an object.
    
    Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +1 −1  lib/jasmine-core/jasmine.js
  2. +1 −1  src/core/base.js
View
2  lib/jasmine-core/jasmine.js
@@ -1,4 +1,4 @@
-var isCommonJS = typeof window == "undefined";
+var isCommonJS = typeof window == "undefined" && typeof exports == "object";
/**
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
View
2  src/core/base.js
@@ -1,4 +1,4 @@
-var isCommonJS = typeof window == "undefined";
+var isCommonJS = typeof window == "undefined" && typeof exports == "object";
/**
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
Something went wrong with that request. Please try again.