Skip to content

Commit

Permalink
Remove Rollup pre-proccesor from Karma runner (#8935)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops committed Apr 27, 2023
1 parent 327467b commit 058c3de
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 11 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -110,29 +110,32 @@ 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
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

Expand Down
23 changes: 0 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
121 changes: 0 additions & 121 deletions spec/index.html

This file was deleted.

97 changes: 13 additions & 84 deletions spec/karma.conf.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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',
Expand All @@ -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
Expand Down

0 comments on commit 058c3de

Please sign in to comment.