mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-20 16:37:08 +00:00
Run test with the source files (#9609)
This commit is contained in:
@ -23,7 +23,7 @@ const config = {
|
||||
}
|
||||
],
|
||||
plugins: [
|
||||
release ? json() : rollupGitVersion()
|
||||
release ? json() : rollupGitVersion(),
|
||||
]
|
||||
};
|
||||
|
||||
|
@ -8,6 +8,11 @@ export default [
|
||||
{
|
||||
files: ['*.js', '*.cjs'],
|
||||
},
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: [
|
||||
'dist',
|
||||
|
750
package-lock.json
generated
750
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,9 +8,9 @@
|
||||
"@rollup/plugin-json": "^6.1.0",
|
||||
"bundlemon": "^3.0.3",
|
||||
"chai": "^5.1.1",
|
||||
"eslint": "^9.8.0",
|
||||
"eslint": "^9.23.0",
|
||||
"eslint-config-mourner": "^4.0.2",
|
||||
"eslint-plugin-import-x": "^3.1.0",
|
||||
"eslint-plugin-import-x": "^4.9.1",
|
||||
"http-server": "^14.1.1",
|
||||
"husky": "^9.1.4",
|
||||
"karma": "^6.4.3",
|
||||
|
@ -12,7 +12,8 @@ Reloaded before every execution run.
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"leaflet": "/base/dist/leaflet-src.js",
|
||||
"leaflet": "/base/src/Leaflet.js",
|
||||
"leaflet-bundle": "/base/dist/leaflet-src.js",
|
||||
"chai": "/base/node_modules/chai/chai.js",
|
||||
"prosthetic-hand": "/base/node_modules/prosthetic-hand/lib/Hand.js",
|
||||
"sinon": "/base/node_modules/sinon/pkg/sinon-esm.js",
|
||||
|
@ -14,7 +14,7 @@ just for immediate execution, without reporting to Karma server.
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"leaflet": "/base/dist/leaflet-src.js",
|
||||
"leaflet": "/base/src/Leaflet.js",
|
||||
"chai": "/base/node_modules/chai/chai.js",
|
||||
"prosthetic-hand": "/base/node_modules/prosthetic-hand/lib/Hand.js",
|
||||
"sinon": "/base/node_modules/sinon/pkg/sinon-esm.js",
|
||||
|
18
spec/karma-version-preprocessor.cjs
Normal file
18
spec/karma-version-preprocessor.cjs
Normal file
@ -0,0 +1,18 @@
|
||||
// Replace version import from package.json with static version for Firefox which currently not supports Import Attributes.
|
||||
// TODO: After Firefox supports Import Attributes, remove this preprocessor and update the karma.conf.cjs file.
|
||||
function replaceVersionPreprocessor(config) {
|
||||
const replaceVersionImport = config.browsers.some(browser => browser.includes('Firefox'));
|
||||
return function (content, file, done) {
|
||||
if (replaceVersionImport) {
|
||||
content = content.replace(
|
||||
/import pkg from '\.\.\/package\.json' with \{ type: 'json' \};/,
|
||||
'const pkg = {version: "0.0.0"};'
|
||||
);
|
||||
// we use error to make it visible in the console
|
||||
console.error('Version import replaced with static variable', file.originalPath, config.browsers.join(', '));
|
||||
}
|
||||
done(content);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = replaceVersionPreprocessor;
|
@ -10,8 +10,12 @@ module.exports = function (/** @type {import('karma').Config} */ config) {
|
||||
'karma-chrome-launcher',
|
||||
'karma-safarinative-launcher',
|
||||
'karma-firefox-launcher',
|
||||
'karma-time-stats-reporter'
|
||||
'karma-time-stats-reporter',
|
||||
{'preprocessor:replaceVersion': ['factory', require('./karma-version-preprocessor.cjs')]}
|
||||
],
|
||||
preprocessors: {
|
||||
'src/Leaflet.js': ['replaceVersion'] // Replace version import from package.json with static version for Firefox which currently not supports Import Attributes.
|
||||
},
|
||||
frameworks: ['mocha'],
|
||||
customContextFile: 'spec/context.html',
|
||||
customDebugFile: 'spec/debug.html',
|
||||
@ -20,7 +24,9 @@ module.exports = function (/** @type {import('karma').Config} */ config) {
|
||||
{pattern: 'node_modules/prosthetic-hand/**/*', included: false, served: true},
|
||||
{pattern: 'node_modules/sinon/**/*', included: false, served: true},
|
||||
{pattern: 'node_modules/ui-event-simulator/**/*', included: false, served: true},
|
||||
{pattern: 'dist/**/*.js', included: false, served: true},
|
||||
{pattern: 'dist/leaflet-src.js', included: false, served: true},
|
||||
{pattern: 'src/**/*.js', included: false, served: true},
|
||||
{pattern: 'package.json', included: false, served: true},
|
||||
{pattern: 'dist/**/*.png', included: false, served: true},
|
||||
{pattern: 'spec/setup.js', type: 'module'},
|
||||
{pattern: 'spec/suites/**/*.js', type: 'module'},
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* global L */
|
||||
import 'leaflet';
|
||||
import L from 'leaflet-bundle';
|
||||
import {expect} from 'chai';
|
||||
|
||||
describe('General', () => {
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
import {version} from '../package.json';
|
||||
export {version};
|
||||
import pkg from '../package.json' with { type: 'json' };
|
||||
export const version = pkg.version;
|
||||
|
||||
// control
|
||||
export * from './control/index.js';
|
||||
|
Reference in New Issue
Block a user