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

Fix Jasmine reporter losing spec results when pretty printing JSDOM nodes #723

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/testRunners/jasmine/JasmineFormatter.js
Expand Up @@ -111,8 +111,8 @@ class JasmineFormatter {
if (this._jasmine.isDomNode(obj)) {
let attrStr = '';
Array.prototype.forEach.call(obj.attributes, attr => {
const attrName = attr.nodeName.trim();
const attrValue = attr.nodeValue.trim();
const attrName = attr.name.trim();
const attrValue = attr.value.trim();
attrStr += ' ' + attrName + '="' + attrValue + '"';
});
return (
Expand Down
42 changes: 42 additions & 0 deletions src/testRunners/jasmine/__tests__/JasmineFormatter-test.js
@@ -0,0 +1,42 @@
/**
* Copyright (c) 2016, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails oncall+jsinfra
*/
'use strict';

jest.autoMockOff();

const path = require('path');
const VENDOR_PATH = path.resolve(__dirname, '../../../../vendor');

const jasmine = require(`${VENDOR_PATH}/jasmine/jasmine-1.3.0`).jasmine;
const jasmine2Require = require(`${VENDOR_PATH}/jasmine/jasmine-2.3.4.js`);
const jasmine2 = jasmine2Require.core(jasmine2Require);

const JasmineFormatter = require('../JasmineFormatter');

const jsdom = require('jsdom').jsdom;
const fixture = '<html><body id="foo"></body></html>';

let formatter;

describe('JasmineFormatter', () => {
describe('pretty printer', () => {
it('should handle JSDOM nodes with Jasmine 1.x', () => {
formatter = new JasmineFormatter(jasmine);

expect(() => formatter.prettyPrint(jsdom(fixture).body)).not.toThrow();
});

it('should handle JSDOM nodes with Jasmine 2.x', () => {
formatter = new JasmineFormatter(jasmine2);

expect(() => formatter.prettyPrint(jsdom(fixture).body)).not.toThrow();
});
});
});