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

test: test use webpack5 and ModuleFederationPlugin #2853

Merged
merged 2 commits into from
Nov 23, 2020
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
24 changes: 24 additions & 0 deletions test/fixtures/module-federation-config/webpack.plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

const ModuleFederationPlugin = require('webpack').container
.ModuleFederationPlugin;

module.exports = {
mode: 'development',
target: 'node',
context: __dirname,
entry: ['./entry1.js'],
plugins: [
new ModuleFederationPlugin({
name: 'app1',
library: { type: 'var', name: 'app1' },
filename: 'remoteEntry.js',
exposes: {
'./entry1': './entry1',
},
}),
],
infrastructureLogging: {
level: 'warn',
},
};
28 changes: 28 additions & 0 deletions test/integration/ModuleFederation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ const simpleConfig = require('../fixtures/module-federation-config/webpack.confi
const objectEntryConfig = require('../fixtures/module-federation-config/webpack.object-entry.config');
const multiConfig = require('../fixtures/module-federation-config/webpack.multi.config');
const port = require('../ports-map').ModuleFederation;
const isWebpack5 = require('../helpers/isWebpack5');

let pluginConfig;

if (isWebpack5) {
pluginConfig = require('../fixtures/module-federation-config/webpack.plugin');
}

describe('module federation', () => {
describe.each([
Expand Down Expand Up @@ -52,4 +59,25 @@ describe('module federation', () => {
});
}
});

(isWebpack5 ? describe : describe.skip)('use plugin', () => {
let server;
let req;

beforeAll((done) => {
server = testServer.start(pluginConfig, { port }, done);
req = request(server.app);
});

afterAll(testServer.close);

it('should contain hot script', async () => {
const { statusCode } = await req.get('/remoteEntry.js');
expect(statusCode).toEqual(200);
await req.get('/main.js').expect(200, /webpack\/hot\/dev-server\.js/);
await req
.get('/remoteEntry.js')
.expect(200, /webpack\/hot\/dev-server\.js/);
});
});
});