Skip to content

'console' is undefined with Qunit in IE 9  #212

@carhartl

Description

@carhartl

Expected Behavior

QUnit test suite with 1 simple test passes successfully.

Actual Behavior

QUnit test suite with 1 simple test fails with global failure due to error `'console' is undefined (see screenshot).

Steps to Reproduce the Problem

  1. single test suite index.html
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Test Suite</title>
		<link href="node_modules/qunitjs/qunit/qunit.css" rel="stylesheet">
		<script src="node_modules/qunitjs/qunit/qunit.js"></script>
		<script>
			QUnit.test('simple value', function (assert) {
				assert.expect(1);
				assert.strictEqual(true, true, 'testing...');
			});
		</script>
	</head>
	<body>
		<div id="qunit"></div>
		<div id="qunit-fixture"></div>
	</body>
</html>
  1. browserstack config:
{
    "test_framework" : "qunit",
    "test_path": [
        "index.html"
    ],
    "exit_with_fail": true,
    "browsers": [
        "ie_9"
    ]
}
  1. Execute node_modules/.bin/browserstack-runner

Platform details

  1. browserstack-runner version: 0.9.0
  2. node version: v11.6.0
  3. os type and version: OSX Mojave 10.14.2

Details

See screenshot:

screenshot 2019-01-02 at 19 22 54

The error points to:

var browserstack_console = console || window.console || {};

If I remember IE pecularities correctly this might be because you cannot do var x = foo || ... when foo has never been set up before, i.e. is very much indeed undefined. A test like typeof foo == 'undefined' might work better/be needed. This could be IE 6-8 knowledge though.

PS: also, the runner will just hang until it times out...

Launching 1 worker(s) for 1 run(s).
[Windows 7, Internet Explorer 9.0] Launching
[Windows 7, Internet Explorer 9.0] Received ack
[Windows 7, Internet Explorer 9.0] Launched
[Windows 7, Internet Explorer 9.0] Awaiting ack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions