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 tests #1475

Merged
merged 1 commit into from
Dec 19, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const WebpackDevRelay = require("../../../lib/dev-admin/webpack-dev-relay");
const { asyncVerify } = require("run-verify");
const _ = require("lodash");

describe.only("webpack-dev-relay", function() {
describe("webpack-dev-relay", function() {
it("should clear webpack dev data if dev server exits", () => {
const wdr = new WebpackDevRelay();
const wds = new EventEmitter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,45 @@ const moduleName = "../../config/webpack/util/generate-config";
describe("generate-config", function() {
this.timeout(10000);

before(() => {
});
before(() => {});

beforeEach(() => {
});
beforeEach(() => {});

afterEach(() => {
delete require.cache[require.resolve(moduleName)];
});

after(() => {
});
after(() => {});

describe("generateConfig", () => {
it("If the configFilename is development.js and only webpack.config.development.js exists, fall back to archetype webpack", () => {
const { generateConfig } = require(moduleName);
const configFilename = "development.js";
const configFilename = "webpack.config.dev.js";
const defaultFilename = "webpack.config.development.js";

const defaultWebpackPath = Path.join(process.cwd(), defaultFilename);
const defaultWebpackContents = {test: 1};
const defaultWebpackContents = { test: 1 };
mockRequire(defaultWebpackPath, defaultWebpackContents);

const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), configFilename);
const archWebpackContents = {test: 2};
const archWebpackContents = { test: 2 };
mockRequire(archWebpackPath, archWebpackContents);

const config = generateConfig({
profiles: {
_base: {
partials: {}
const config = generateConfig(
{
profiles: {
_base: {
partials: {}
},
_production: {
partials: {}
}
},
_production: {
partials: {}
}
profileNames: ["_base", "_production"],
configFilename: "development.js"
},
profileNames: [ "_base", "_production" ],
configFilename
}, true);
true
);

expect(config).to.deep.equal(archWebpackContents);

Expand All @@ -59,25 +59,28 @@ describe("generate-config", function() {
const defaultFilename = "webpack.config.dev.js";

const defaultWebpackPath = Path.join(process.cwd(), defaultFilename);
const defaultWebpackContents = {test: 3};
const defaultWebpackContents = { test: 3 };
mockRequire(defaultWebpackPath, defaultWebpackContents);

const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), configFilename);
const archWebpackContents = {test: 4};
const archWebpackContents = { test: 4 };
mockRequire(archWebpackPath, archWebpackContents);

const config = generateConfig({
profiles: {
_base: {
partials: {}
const config = generateConfig(
{
profiles: {
_base: {
partials: {}
},
_production: {
partials: {}
}
},
_production: {
partials: {}
}
profileNames: ["_base", "_production"],
configFilename
},
profileNames: [ "_base", "_production" ],
configFilename
}, true);
true
);

expect(config).to.deep.equal(defaultWebpackContents);

Expand All @@ -87,28 +90,32 @@ describe("generate-config", function() {

it("If the configName is coverage.js and only coverage.js exists, fall back to archetype webpack", () => {
const { generateConfig } = require(moduleName);
const configFilename = "coverage.js";
const defaultFilename = "coverage.js";
const configFilename = "webpack.config.coverage.js";

const configWebpackPath = Path.join(process.cwd(), configFilename);
const configWebpackContents = {test: 5};
const configWebpackPath = Path.join(process.cwd(), defaultFilename);
const configWebpackContents = { test: 5 };
mockRequire(configWebpackPath, configWebpackContents);

const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), configFilename);
const archWebpackContents = {test: 6};
const archWebpackContents = { test: 6 };
mockRequire(archWebpackPath, archWebpackContents);

const config = generateConfig({
profiles: {
_base: {
partials: {}
const config = generateConfig(
{
profiles: {
_base: {
partials: {}
},
_production: {
partials: {}
}
},
_production: {
partials: {}
}
profileNames: ["_base", "_production"],
configFilename: defaultFilename
},
profileNames: [ "_base", "_production" ],
configFilename
}, true);
true
);

expect(config).to.deep.equal(archWebpackContents);

Expand All @@ -122,25 +129,28 @@ describe("generate-config", function() {
const defaultFilename = "webpack.config.coverage.js";

const configWebpackPath = Path.join(process.cwd(), defaultFilename);
const configWebpackContents = {test: 7};
const configWebpackContents = { test: 7 };
mockRequire(configWebpackPath, configWebpackContents);

const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), configFilename);
const archWebpackContents = {test: 8};
const archWebpackContents = { test: 8 };
mockRequire(archWebpackPath, archWebpackContents);

const config = generateConfig({
profiles: {
_base: {
partials: {}
const config = generateConfig(
{
profiles: {
_base: {
partials: {}
},
_production: {
partials: {}
}
},
_production: {
partials: {}
}
profileNames: ["_base", "_production"],
configFilename
},
profileNames: [ "_base", "_production" ],
configFilename
}, true);
true
);

expect(config).to.deep.equal(configWebpackContents);

Expand All @@ -151,27 +161,31 @@ describe("generate-config", function() {
it("If the configName is production.js and only production.js exists, fall back to archetype webpack", () => {
const { generateConfig } = require(moduleName);
const configFilename = "production.js";
const archFilename = "webpack.config.js";

const configWebpackPath = Path.join(process.cwd(), configFilename);
const configWebpackContents = {test: 9};
const configWebpackContents = { test: 9 };
mockRequire(configWebpackPath, configWebpackContents);

const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), configFilename);
const archWebpackContents = {test: 10};
const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), archFilename);
const archWebpackContents = { test: 10 };
mockRequire(archWebpackPath, archWebpackContents);

const config = generateConfig({
profiles: {
_base: {
partials: {}
const config = generateConfig(
{
profiles: {
_base: {
partials: {}
},
_production: {
partials: {}
}
},
_production: {
partials: {}
}
profileNames: ["_base", "_production"],
configFilename
},
profileNames: [ "_base", "_production" ],
configFilename
}, true);
true
);

expect(config).to.deep.equal(archWebpackContents);

Expand All @@ -182,28 +196,32 @@ describe("generate-config", function() {
it("If the configName is production.js and only webpack.config.production.js exists, fall back to archetype webpack", () => {
const { generateConfig } = require(moduleName);
const configFilename = "production.js";
const archFilename = "webpack.config.js";
const defaultFilename = "webpack.config.production.js";

const configWebpackPath = Path.join(process.cwd(), defaultFilename);
const configWebpackContents = {test: 11};
const configWebpackContents = { test: 11 };
mockRequire(configWebpackPath, configWebpackContents);

const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), configFilename);
const archWebpackContents = {test: 12};
const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), archFilename);
const archWebpackContents = { test: 12 };
mockRequire(archWebpackPath, archWebpackContents);

const config = generateConfig({
profiles: {
_base: {
partials: {}
const config = generateConfig(
{
profiles: {
_base: {
partials: {}
},
_production: {
partials: {}
}
},
_production: {
partials: {}
}
profileNames: ["_base", "_production"],
configFilename
},
profileNames: [ "_base", "_production" ],
configFilename
}, true);
true
);

expect(config).to.deep.equal(archWebpackContents);

Expand All @@ -217,25 +235,28 @@ describe("generate-config", function() {
const defaultFilename = "webpack.config.js";

const configWebpackPath = Path.join(process.cwd(), defaultFilename);
const configWebpackContents = {test: 13};
const configWebpackContents = { test: 13 };
mockRequire(configWebpackPath, configWebpackContents);

const archWebpackPath = Path.join(Path.resolve("archetype/config/webpack"), configFilename);
const archWebpackContents = {test: 14};
const archWebpackContents = { test: 14 };
mockRequire(archWebpackPath, archWebpackContents);

const config = generateConfig({
profiles: {
_base: {
partials: {}
const config = generateConfig(
{
profiles: {
_base: {
partials: {}
},
_production: {
partials: {}
}
},
_production: {
partials: {}
}
profileNames: ["_base", "_production"],
configFilename
},
profileNames: [ "_base", "_production" ],
configFilename
}, true);
true
);

expect(config).to.deep.equal(configWebpackContents);

Expand All @@ -247,18 +268,21 @@ describe("generate-config", function() {
const { generateConfig } = require(moduleName);
const configFilename = "production.js";

const config = generateConfig({
profiles: {
_base: {
partials: {}
const config = generateConfig(
{
profiles: {
_base: {
partials: {}
},
_production: {
partials: {}
}
},
_production: {
partials: {}
}
profileNames: ["_base", "_production"],
configFilename
},
profileNames: [ "_base", "_production" ],
configFilename
}, true);
true
);

expect(config).to.deep.equal({});
});
Expand Down