Skip to content

Commit

Permalink
Add tests for sourcemap support
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeochoa committed May 3, 2017
1 parent 494b252 commit ee757f9
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/jest-runtime/src/__tests__/Runtime-sourceMaps-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2014-present, 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';

let createRuntime;

describe('Runtime', () => {
beforeEach(() => {
createRuntime = require('createRuntime');
});

describe('requireModule', () => {
it('installs source maps if available', () =>
createRuntime(__filename).then(runtime => {
let hasThrown = false;
const sum = runtime.requireModule(
runtime.__mockRootPath,
'./sourcemaps/out/throwing-mapped-fn.js',
).sum;

try {
sum();
} catch (err) {
hasThrown = true;
/* eslint-disable max-len */
if (process.platform === 'win32') {
expect(err.stack).toMatch(
/^Error: throwing fn\s+at sum.+\\__tests__\\test_root\\sourcemaps\\throwing-mapped-fn.js:10:9/,
);
} else {
expect(err.stack).toMatch(
/^Error: throwing fn\s+at sum.+\/__tests__\/test_root\/sourcemaps\/throwing-mapped-fn.js:10:9/,
);
}
/* eslint-enable max-len */
}
expect(hasThrown).toBe(true);
}));
});
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) 2014-present, 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.
*/

export function sum() {
throw new Error('throwing fn');
}

0 comments on commit ee757f9

Please sign in to comment.