Fixes for breaking changes

- new webpack dev server options
- babel support for async functions in hooks
- new uuid import style
- automatically open browser for testing
This commit is contained in:
Filip Proborszcz 2022-04-08 02:23:43 +02:00
parent ab00c9f426
commit d73add77e7
8 changed files with 48 additions and 51 deletions

View file

@ -6,7 +6,8 @@
"plugins": [ "plugins": [
"static-fs", "static-fs",
"react-hot-loader/babel", "react-hot-loader/babel",
"@babel/plugin-proposal-class-properties" "@babel/plugin-proposal-class-properties",
"@babel/transform-runtime"
], ],
"env": { "env": {
"test": { "test": {

View file

@ -3,7 +3,6 @@ var WebpackDevServer = require("webpack-dev-server");
var webpackConfig = require("./webpack.config"); var webpackConfig = require("./webpack.config");
var testConfig = require("../test/config/specs"); var testConfig = require("../test/config/specs");
var artifacts = require("../test/artifacts"); var artifacts = require("../test/artifacts");
var isDocker = require("is-docker");
var server; var server;
@ -22,6 +21,7 @@ exports.config = {
browserName: (process.env.BROWSER || 'chrome'), browserName: (process.env.BROWSER || 'chrome'),
} }
], ],
services: ['selenium-standalone'],
logLevel: 'info', logLevel: 'info',
bail: 0, bail: 0,
screenshotPath: SCREENSHOT_PATH, screenshotPath: SCREENSHOT_PATH,
@ -33,39 +33,14 @@ exports.config = {
// Because we don't know how long the initial build will take... // Because we don't know how long the initial build will take...
timeout: 4*60*1000, timeout: 4*60*1000,
}, },
onPrepare: function (config, capabilities) { onPrepare: async function (config, capabilities) {
return new Promise(function(resolve, reject) { webpackConfig.devServer.host = testConfig.testNetwork;
var compiler = webpack(webpackConfig); webpackConfig.devServer.port = testConfig.port;
const serverHost = "0.0.0.0"; const compiler = webpack(webpackConfig);
server = new WebpackDevServer(webpackConfig.devServer, compiler);
server = new WebpackDevServer(compiler, { await server.start();
host: serverHost,
disableHostCheck: true,
stats: {
colors: true
}
});
server.listen(testConfig.port, serverHost, function(err) {
if(err) {
reject(err);
}
else {
resolve();
}
});
})
}, },
onComplete: function(exitCode) { onComplete: async function (exitCode, config, capabilities) {
return new Promise(function(resolve, reject) { await server.stop();
server.close(function (err) {
if (err) {
reject(err)
}
else {
resolve();
}
})
});
} }
} }

View file

@ -1,5 +1,4 @@
"use strict"; "use strict";
var webpack = require('webpack');
var path = require('path'); var path = require('path');
var rules = require('./webpack.rules'); var rules = require('./webpack.rules');
var HtmlWebpackPlugin = require('html-webpack-plugin'); var HtmlWebpackPlugin = require('html-webpack-plugin');
@ -52,9 +51,10 @@ module.exports = {
} }
} }
}, },
optimization: {
noEmitOnErrors: true,
},
plugins: [ plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
title: 'Maputnik', title: 'Maputnik',
template: './src/template.html' template: './src/template.html'

36
package-lock.json generated
View file

@ -6675,6 +6675,16 @@
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA=="
}, },
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"dev": true,
"optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"bl": { "bl": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
@ -10505,6 +10515,13 @@
} }
} }
}, },
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"dev": true,
"optional": true
},
"filelist": { "filelist": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz",
@ -12445,12 +12462,6 @@
} }
} }
}, },
"is-docker": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
"integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==",
"dev": true
},
"is-dom": { "is-dom": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-dom/-/is-dom-1.1.0.tgz", "resolved": "https://registry.npmjs.org/is-dom/-/is-dom-1.1.0.tgz",
@ -14652,6 +14663,13 @@
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
"dev": true "dev": true
}, },
"nan": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==",
"dev": true,
"optional": true
},
"nanoid": { "nanoid": {
"version": "3.3.1", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz",
@ -20141,7 +20159,11 @@
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
"dev": true, "dev": true,
"optional": true "optional": true,
"requires": {
"bindings": "^1.5.0",
"nan": "^2.12.1"
}
}, },
"glob-parent": { "glob-parent": {
"version": "3.1.0", "version": "3.1.0",

View file

@ -26,6 +26,7 @@
"license": "MIT", "license": "MIT",
"homepage": "https://github.com/maputnik/editor#readme", "homepage": "https://github.com/maputnik/editor#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.17.9",
"@mapbox/mapbox-gl-rtl-text": "^0.2.3", "@mapbox/mapbox-gl-rtl-text": "^0.2.3",
"@mapbox/mapbox-gl-style-spec": "^13.23.1", "@mapbox/mapbox-gl-style-spec": "^13.23.1",
"@mdi/react": "^1.5.0", "@mdi/react": "^1.5.0",
@ -148,7 +149,6 @@
"express": "^4.17.3", "express": "^4.17.3",
"html-webpack-inline-svg-plugin": "^2.3.0", "html-webpack-inline-svg-plugin": "^2.3.0",
"html-webpack-plugin": "^4.5.2", "html-webpack-plugin": "^4.5.2",
"is-docker": "^3.0.0",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"istanbul-lib-coverage": "^3.2.0", "istanbul-lib-coverage": "^3.2.0",
"mkdirp": "^1.0.4", "mkdirp": "^1.0.4",

View file

@ -1,7 +1,6 @@
var config = {}; var config = {};
var testNetwork = process.env.TEST_NETWORK || "localhost"; config.testNetwork = process.env.TEST_NETWORK || "localhost";
config.port = 9001; config.port = 9001;
config.baseUrl = "http://"+testNetwork+":"+config.port; config.baseUrl = "http://"+config.testNetwork+":"+config.port;
module.exports = config; module.exports = config;

View file

@ -1,5 +1,5 @@
var wd = require("../wd-helper"); var wd = require("../wd-helper");
var uuid = require('uuid/v1'); var {v1: uuid} = require('uuid');
var geoServer = require("../geojson-server"); var geoServer = require("../geojson-server");
var testNetwork = process.env.TEST_NETWORK || "localhost"; var testNetwork = process.env.TEST_NETWORK || "localhost";

View file

@ -1,7 +1,7 @@
var assert = require("assert"); var assert = require("assert");
var config = require("../../config/specs"); var config = require("../../config/specs");
var helper = require("../helper"); var helper = require("../helper");
var uuid = require('uuid/v1'); var {v1: uuid} = require('uuid');
var wd = require("../../wd-helper"); var wd = require("../../wd-helper");