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

Run tests against source, CJS, and UMD builds #6209

Merged
merged 6 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/react-router-config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
let mappedModule;
switch (process.env.TEST_ENV) {
case "cjs":
mappedModule = "<rootDir>/cjs/react-router-config.js";
break;
case "umd":
mappedModule = "<rootDir>/umd/react-router-config.js";
break;
default:
mappedModule = "<rootDir>/modules/index";
}

module.exports = {
testRunner: "jest-circus/runner",
restoreMocks: true,
Expand All @@ -6,7 +18,7 @@ module.exports = {
},
moduleNameMapper: {
"^react-router$": "<rootDir>/../react-router/cjs/react-router.js",
"^react-router-config$": "<rootDir>/cjs/react-router-config.js"
"^react-router-config$": mappedModule
},
modulePaths: ["<rootDir>/node_modules"],
setupFiles: ["raf/polyfill"],
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"build": "del cjs esm umd && rollup -c",
"prepublishOnly": "del cjs esm umd && rollup -c",
"lint": "eslint modules",
"test": "jest"
"test": "node ./scripts/test.js"
},
"peerDependencies": {
"react": ">=15",
Expand Down
25 changes: 25 additions & 0 deletions packages/react-router-config/scripts/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const execSync = require("child_process").execSync;

const exec = (command, extraEnv) =>
execSync(command, {
stdio: "inherit",
env: Object.assign({}, process.env, extraEnv)
});

console.log("Testing source files");

exec("jest", {
TEST_ENV: "source"
});

console.log("Testing commonjs build");

exec("jest", {
TEST_ENV: "cjs"
});

console.log("Testing UMD build");

exec("jest", {
TEST_ENV: "umd"
});
14 changes: 13 additions & 1 deletion packages/react-router-dom/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
let mappedModule;
switch (process.env.TEST_ENV) {
case "cjs":
mappedModule = "<rootDir>/cjs/react-router-dom.js";
break;
case "umd":
mappedModule = "<rootDir>/umd/react-router-dom.js";
break;
default:
mappedModule = "<rootDir>/modules/index";
}

module.exports = {
testRunner: "jest-circus/runner",
restoreMocks: true,
globals: {
__DEV__: true
},
moduleNameMapper: {
"^react-router-dom$": "<rootDir>/cjs/react-router-dom.js"
"^react-router-dom$": mappedModule
},
modulePaths: ["<rootDir>/node_modules"],
setupFiles: ["raf/polyfill"],
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"build": "del cjs esm umd && rollup -c",
"prepublishOnly": "del cjs esm umd && rollup -c",
"lint": "eslint modules",
"test": "jest"
"test": "node ./scripts/test.js"
},
"peerDependencies": {
"react": ">=15"
Expand Down
25 changes: 25 additions & 0 deletions packages/react-router-dom/scripts/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const execSync = require("child_process").execSync;

const exec = (command, extraEnv) =>
execSync(command, {
stdio: "inherit",
env: Object.assign({}, process.env, extraEnv)
});

console.log("Testing source files");

exec("jest", {
TEST_ENV: "source"
});

console.log("Testing commonjs build");

exec("jest", {
TEST_ENV: "cjs"
});

console.log("Testing UMD build");

exec("jest", {
TEST_ENV: "umd"
});
14 changes: 13 additions & 1 deletion packages/react-router/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
let mappedModule;
switch (process.env.TEST_ENV) {
case "cjs":
mappedModule = "<rootDir>/cjs/react-router.js";
break;
case "umd":
mappedModule = "<rootDir>/umd/react-router.js";
break;
default:
mappedModule = "<rootDir>/modules/index";
}

module.exports = {
testRunner: "jest-circus/runner",
restoreMocks: true,
globals: {
__DEV__: true
},
moduleNameMapper: {
"^react-router$": "<rootDir>/cjs/react-router.js"
"^react-router$": mappedModule
},
modulePaths: ["<rootDir>/node_modules"],
setupFiles: ["raf/polyfill"],
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/modules/__tests__/Route-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import ReactDOM from "react-dom";
import { createMemoryHistory as createHistory } from "history";
import { MemoryRouter, Route, Router } from "react-router";
import { MemoryRouter, Router, Route } from "react-router";

import renderStrict from "./utils/renderStrict";

Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build": "del cjs esm umd && rollup -c",
"prepublishOnly": "del cjs esm umd && rollup -c",
"lint": "eslint modules",
"test": "jest"
"test": "node ./scripts/test.js"
},
"peerDependencies": {
"react": ">=15"
Expand Down
25 changes: 25 additions & 0 deletions packages/react-router/scripts/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const execSync = require("child_process").execSync;

const exec = (command, extraEnv) =>
execSync(command, {
stdio: "inherit",
env: Object.assign({}, process.env, extraEnv)
});

console.log("Testing source files");

exec("jest", {
TEST_ENV: "source"
});

console.log("Testing commonjs build");

exec("jest", {
TEST_ENV: "cjs"
});

console.log("Testing UMD build");

exec("jest", {
TEST_ENV: "umd"
});