mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-20 16:37:08 +00:00
Remove Rollup pre-proccesor from Karma runner (#8935)
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -125,7 +125,7 @@ jobs:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Run tests on ${{ matrix.browser }}
|
||||
run: npm test -- --browsers ${{ matrix.browser }}
|
||||
run: npm test -- --browsers ${{ matrix.browser }} --single-run
|
||||
|
||||
publish-artifacts:
|
||||
needs: setup
|
||||
|
@ -97,7 +97,7 @@ Also, please make sure that you have [line endings configured properly](https://
|
||||
|
||||
Happy coding!
|
||||
|
||||
### Using RollupJS
|
||||
### Building Leaflet
|
||||
|
||||
The source JavaScript code for Leaflet is a few dozen files, in the `src/` directory.
|
||||
But normally, Leaflet is loaded in a web browser as just one JavaScript file.
|
||||
@ -110,7 +110,7 @@ development. `dist/leaflet.js` is uglified and thus is smaller, so it's better
|
||||
for deployment.
|
||||
|
||||
When developing (or bugfixing) core Leaflet functionalities, it's common to use
|
||||
the webpages in the `debug/` directory, and run the unit tests (`spec/index.html`)
|
||||
the webpages in the `debug/` directory, and run the tests
|
||||
in a graphical browser. This requires regenerating the bundled files quickly.
|
||||
|
||||
In order to do so, run `npm run watch` or `yarn run watch`. This will keep
|
||||
@ -118,21 +118,24 @@ on rebuilding the bundles whenever any source file changes.
|
||||
|
||||
## Running the Tests
|
||||
|
||||
To run the tests from the command line, install [Google Chrome](https://www.google.com/chrome/) then run:
|
||||
Before running the tests make sure that the source code has been built (as mentioned above). If you want to run the tests in the background while working on Leaflet it is recommended you run the build in `watch` mode. This way the tests will automatically re-run when changes to the source code are made.
|
||||
|
||||
To run the tests from the command line, ensure you have [Google Chrome](https://www.google.com/chrome/) installed and then run:
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
To run the tests in other browsers at the same time, you can do:
|
||||
By default the tests will run in Google Chrome headlessly (without a UI), to run the tests in other browsers you can pass in the [`--browsers`](https://karma-runner.github.io/latest/config/configuration-file.html#browsers) flag.
|
||||
|
||||
```
|
||||
npm test -- -- --browsers Firefox,Chrome,Safari,IE
|
||||
npm test -- --browsers Firefox
|
||||
```
|
||||
|
||||
(Note: the doubling of "`--`" [special option](https://docs.npmjs.com/cli/run-script#description) is [important](https://github.com/Leaflet/Leaflet/pull/6166#issuecomment-390959903))
|
||||
|
||||
To run the tests in a browser manually, open `spec/index.html`.
|
||||
For a list of available browsers see the documentation of the included launcher plugins:
|
||||
- [`karma-chrome-launcher`](https://github.com/karma-runner/karma-chrome-launcher#available-browsers)
|
||||
- [`karma-firefox-launcher`](https://github.com/karma-runner/karma-firefox-launcher#configuration)
|
||||
- [`karma-safarinative-launcher`](https://github.com/muthu90ec/karma-safarinative-launcher#readme)
|
||||
|
||||
## Improving Documentation
|
||||
|
||||
|
23
package-lock.json
generated
23
package-lock.json
generated
@ -22,7 +22,6 @@
|
||||
"karma-expect": "^1.1.3",
|
||||
"karma-firefox-launcher": "^2.1.2",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-rollup-preprocessor": "^7.0.8",
|
||||
"karma-safarinative-launcher": "^1.1.0",
|
||||
"karma-sinon": "^1.0.5",
|
||||
"karma-time-stats-reporter": "^0.1.0",
|
||||
@ -1292,12 +1291,6 @@
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/debounce": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz",
|
||||
"integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
@ -3169,22 +3162,6 @@
|
||||
"minimist": "^1.2.3"
|
||||
}
|
||||
},
|
||||
"node_modules/karma-rollup-preprocessor": {
|
||||
"version": "7.0.8",
|
||||
"resolved": "https://registry.npmjs.org/karma-rollup-preprocessor/-/karma-rollup-preprocessor-7.0.8.tgz",
|
||||
"integrity": "sha512-WiuBCS9qsatJuR17dghiTARBZ7LF+ml+eb7qJXhw7IbsdY0lTWELDRQC/93J9i6636CsAXVBL3VJF4WtaFLZzA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chokidar": "^3.3.1",
|
||||
"debounce": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": ">= 1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/karma-safarinative-launcher": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/karma-safarinative-launcher/-/karma-safarinative-launcher-1.1.0.tgz",
|
||||
|
@ -17,7 +17,6 @@
|
||||
"karma-expect": "^1.1.3",
|
||||
"karma-firefox-launcher": "^2.1.2",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-rollup-preprocessor": "^7.0.8",
|
||||
"karma-safarinative-launcher": "^1.1.0",
|
||||
"karma-sinon": "^1.0.5",
|
||||
"karma-time-stats-reporter": "^0.1.0",
|
||||
|
121
spec/index.html
121
spec/index.html
@ -1,121 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Leaflet Spec Runner</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" type="text/css" href="../node_modules/mocha/mocha.css">
|
||||
<link rel="stylesheet" type="text/css" href="../dist/leaflet.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="../node_modules/expect.js/index.js"></script>
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/ui-event-simulator/ui-event-simulator.js"></script>
|
||||
<script src="../node_modules/prosthetic-hand/dist/prosthetic-hand.js"></script>
|
||||
<script src="../node_modules/sinon/pkg/sinon.js"></script>
|
||||
|
||||
<!-- source files -->
|
||||
<script>
|
||||
// Trick Leaflet into believing we have a touchscreen (for desktop)
|
||||
if (window.TouchEvent) { window.ontouchstart = function(){} };
|
||||
var oldL = window.L;
|
||||
</script>
|
||||
|
||||
<script src="../dist/leaflet-src.js"></script>
|
||||
|
||||
<script>
|
||||
// sets the default imagePath to the project path like "/Leaflet/dist/images/"
|
||||
// same as in after.js but not static
|
||||
L.Icon.Default.imagePath = '/' + window.location.pathname.split('/')[1] + '/dist/images/';
|
||||
</script>
|
||||
|
||||
<script class="mocha-init">
|
||||
mocha.setup('bdd');
|
||||
mocha.checkLeaks();
|
||||
</script>
|
||||
|
||||
<!-- spec files -->
|
||||
<script src="suites/SpecHelper.js"></script>
|
||||
|
||||
<!-- /control -->
|
||||
<script src="suites/control/Control.AttributionSpec.js"></script>
|
||||
<script src="suites/control/Control.LayersSpec.js"></script>
|
||||
<script src="suites/control/Control.ScaleSpec.js"></script>
|
||||
<script src="suites/control/ControlSpec.js"></script>
|
||||
|
||||
<!-- /core -->
|
||||
<script src="suites/core/ClassSpec.js"></script>
|
||||
<script src="suites/core/EventsSpec.js"></script>
|
||||
<script src="suites/core/GeneralSpec.js"></script>
|
||||
<script src="suites/core/UtilSpec.js"></script>
|
||||
|
||||
<!-- /dom -->
|
||||
<script src="suites/dom/DomEvent.DoubleTapSpec.js"></script>
|
||||
<script src="suites/dom/DomEvent.PointerSpec.js"></script>
|
||||
<script src="suites/dom/DomEventSpec.js"></script>
|
||||
<script src="suites/dom/DomUtilSpec.js"></script>
|
||||
|
||||
<!-- /geo -->
|
||||
<script src="suites/geo/LatLngBoundsSpec.js"></script>
|
||||
<script src="suites/geo/LatLngSpec.js"></script>
|
||||
|
||||
<!-- /geo/crs -->
|
||||
<script src="suites/geo/crs/CRSSpec.js"></script>
|
||||
|
||||
<!-- /geo/projection -->
|
||||
<script src="suites/geo/projection/ProjectionSpec.js"></script>
|
||||
|
||||
<!-- /geometry -->
|
||||
<script src="suites/geometry/BoundsSpec.js"></script>
|
||||
<script src="suites/geometry/LineUtilSpec.js"></script>
|
||||
<script src="suites/geometry/PointSpec.js"></script>
|
||||
<script src="suites/geometry/PolyUtilSpec.js"></script>
|
||||
<script src="suites/geometry/TransformationSpec.js"></script>
|
||||
|
||||
<!-- /layer -->
|
||||
<script src="suites/layer/FeatureGroupSpec.js"></script>
|
||||
<script src="suites/layer/GeoJSONSpec.js"></script>
|
||||
<script src="suites/layer/ImageOverlaySpec.js"></script>
|
||||
<script src="suites/layer/LayerGroupSpec.js"></script>
|
||||
<script src="suites/layer/PopupSpec.js"></script>
|
||||
<script src="suites/layer/TooltipSpec.js"></script>
|
||||
<script src="suites/layer/VideoOverlaySpec.js"></script>
|
||||
|
||||
<!-- /layer/marker/ -->
|
||||
<script src="suites/layer/marker/Icon.DefaultSpec.js"></script>
|
||||
<script src="suites/layer/marker/Marker.DragSpec.js"></script>
|
||||
<script src="suites/layer/marker/MarkerSpec.js"></script>
|
||||
|
||||
<!-- /layer/tile -->
|
||||
<script src="suites/layer/tile/GridLayerSpec.js"></script>
|
||||
<script src="suites/layer/tile/TileLayerSpec.js"></script>
|
||||
|
||||
<!-- /layer/vector/ -->
|
||||
<script src="suites/layer/vector/CanvasSpec.js"></script>
|
||||
<script src="suites/layer/vector/CircleMarkerSpec.js"></script>
|
||||
<script src="suites/layer/vector/CircleSpec.js"></script>
|
||||
<script src="suites/layer/vector/PathSpec.js"></script>
|
||||
<script src="suites/layer/vector/PolygonSpec.js"></script>
|
||||
<script src="suites/layer/vector/PolylineSpec.js"></script>
|
||||
<script src="suites/layer/vector/RectangleSpec.js"></script>
|
||||
|
||||
<!-- /map -->
|
||||
<script src="suites/map/MapSpec.js"></script>
|
||||
|
||||
<!-- /map/handler -->
|
||||
<script src="suites/map/handler/Map.BoxZoom.js"></script>
|
||||
<script src="suites/map/handler/Map.DoubleClickZoomSpec.js"></script>
|
||||
<script src="suites/map/handler/Map.DragSpec.js"></script>
|
||||
<script src="suites/map/handler/Map.KeyboardSpec.js"></script>
|
||||
<script src="suites/map/handler/Map.ScrollWheelZoomSpec.js"></script>
|
||||
<script src="suites/map/handler/Map.TapHoldSpec.js"></script>
|
||||
<script src="suites/map/handler/Map.TouchZoomSpec.js"></script>
|
||||
|
||||
<script class="mocha-exec">
|
||||
window.mocha
|
||||
.globals([ '_leaflet_events' ]) // acceptable globals - fixing gloabl leaks
|
||||
.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,32 +1,8 @@
|
||||
const json = require('@rollup/plugin-json');
|
||||
|
||||
// Karma configuration
|
||||
module.exports = function (config) {
|
||||
|
||||
// var libSources = require(__dirname + '/../build/build.js').getFiles();
|
||||
|
||||
const files = [
|
||||
'spec/before.js',
|
||||
'src/LeafletWithGlobals.js',
|
||||
'spec/after.js',
|
||||
'node_modules/ui-event-simulator/ui-event-simulator.js',
|
||||
'node_modules/prosthetic-hand/dist/prosthetic-hand.js',
|
||||
'spec/suites/SpecHelper.js',
|
||||
'spec/suites/**/*.js',
|
||||
'dist/*.css',
|
||||
{pattern: 'dist/images/*.png', included: false, serve: true}
|
||||
];
|
||||
|
||||
const preprocessors = {};
|
||||
|
||||
preprocessors['src/LeafletWithGlobals.js'] = ['rollup'];
|
||||
|
||||
// See: https://karma-runner.github.io/latest/config/configuration-file.html
|
||||
module.exports = function (/** @type {import('karma').Config} */ config) {
|
||||
config.set({
|
||||
// base path, that will be used to resolve files and exclude
|
||||
basePath: '../',
|
||||
|
||||
plugins: [
|
||||
'karma-rollup-preprocessor',
|
||||
'karma-mocha',
|
||||
'karma-sinon',
|
||||
'karma-expect',
|
||||
@ -35,61 +11,28 @@ module.exports = function (config) {
|
||||
'karma-firefox-launcher',
|
||||
'karma-time-stats-reporter'
|
||||
],
|
||||
|
||||
// frameworks to use
|
||||
frameworks: ['mocha', 'sinon', 'expect'],
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files,
|
||||
files: [
|
||||
'spec/before.js',
|
||||
{pattern: 'dist/leaflet-src.js'},
|
||||
'spec/after.js',
|
||||
'node_modules/ui-event-simulator/ui-event-simulator.js',
|
||||
'node_modules/prosthetic-hand/dist/prosthetic-hand.js',
|
||||
'spec/suites/SpecHelper.js',
|
||||
'spec/suites/**/*.js',
|
||||
'dist/*.css',
|
||||
{pattern: 'dist/images/*.png', included: false, served: true}
|
||||
],
|
||||
proxies: {
|
||||
'/base/dist/images/': 'dist/images/'
|
||||
},
|
||||
exclude: [],
|
||||
|
||||
// Rollup the ES6 Leaflet sources into just one file, before tests
|
||||
preprocessors,
|
||||
rollupPreprocessor: {
|
||||
onwarn: () => {}, // silence Rollup warnings
|
||||
plugins: [
|
||||
json()
|
||||
],
|
||||
output: {
|
||||
format: 'umd',
|
||||
name: 'leaflet',
|
||||
freeze: false,
|
||||
},
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
|
||||
reporters: ['progress', 'time-stats'],
|
||||
|
||||
timeStatsReporter: {
|
||||
reportTimeStats: false,
|
||||
longestTestsCount: 10
|
||||
},
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_WARN,
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// Start these browsers, currently available:
|
||||
// - Chrome
|
||||
// - ChromeCanary
|
||||
// - Firefox
|
||||
// - Opera
|
||||
// - SafariNative (only Mac)
|
||||
browsers: ['Chrome1280x1024'],
|
||||
|
||||
customLaunchers: {
|
||||
'Chrome1280x1024': {
|
||||
base: 'ChromeHeadless',
|
||||
@ -116,22 +59,8 @@ module.exports = function (config) {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
concurrency: 1,
|
||||
|
||||
// If browser does not capture in given timeout [ms], kill it
|
||||
captureTimeout: 60000,
|
||||
|
||||
// Timeout for the client socket connection [ms].
|
||||
browserSocketTimeout: 30000,
|
||||
|
||||
// Silence console.warn output in the terminal
|
||||
browserConsoleLogOptions: {level: 'error'},
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, it capture browsers, run tests and exit
|
||||
singleRun: true,
|
||||
|
||||
client: {
|
||||
mocha: {
|
||||
// eslint-disable-next-line no-undef
|
||||
|
Reference in New Issue
Block a user