Skip to content

Commit

Permalink
Update Karma configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
surilindur committed Nov 26, 2024
1 parent 2d170e2 commit ec240db
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 107 deletions.
71 changes: 71 additions & 0 deletions karma.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { webkit } from '@playwright/test';
import * as NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
import { DefinePlugin } from 'webpack';

const testFiles = [
'engines/query-sparql-link-traversal-solid/test/QuerySparqlLinkTraversalSolid-solidbench-test.ts',
];

process.env.WEBKIT_HEADLESS_BIN = webkit.executablePath();

// Based on https://github.com/tom-sherman/blog/blob/main/posts/02-running-jest-tests-in-a-browser.md
function defineConfig(config: any): void {
config.set({
basePath: __dirname,
plugins: [
'karma-webpack',
'karma-jasmine',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-webkit-launcher',
'karma-sourcemap-loader',
'karma-jasmine-html-reporter',
],
frameworks: [ 'jasmine', 'webpack' ],
files: [ './karma.setup.ts', ...testFiles ],
client: {
args: [ '--grep', '/^(?!.*no browser).*$/' ],
},
preprocessors: {
'./karma.setup.ts': [ 'webpack' ],
...Object.fromEntries(testFiles.map(testFile => [ testFile, [ 'webpack', 'sourcemap' ]])),
},
webpack: {
devtool: 'inline-source-map',
mode: 'production',
module: {
rules: [
{
test: /\.ts$/u,
loader: 'ts-loader',
exclude: /node_modules/u,
options: { transpileOnly: true },
},
],
},
plugins: [
new NodePolyfillPlugin({
additionalAliases: [
'process',
],
}),
new DefinePlugin({ 'process.stdout.isTTY': false }),
],
resolve: {
alias: {
fs: false,
module: false,
'jest.unmock': false,
},
extensions: [ '.js', '.ts' ],
},
},
browsers: [
'ChromeHeadless',
'FirefoxHeadless',
'WebkitHeadless',
],
});
};

export default defineConfig;
104 changes: 0 additions & 104 deletions karma.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions karma-setup.js → karma.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ window.test.each = inputs => (testName, test) => {
}
};
window.test.todo = function() {};
window.jest = jest;
window.expect = expect;
(<any>window).jest = jest;
(<any>window).expect = expect;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@comunica/packager": "4.0.1",
"@comunica/utils-jest": "4.0.2",
"@comunica/utils-monorepo": "4.0.1",
"@playwright/test": "^1.49.0",
"@pollyjs/adapter-node-http": "^6.0.6",
"@pollyjs/core": "^6.0.6",
"@pollyjs/persister-fs": "^6.0.6",
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "./tsconfig.json",
"include": [
"engines/**/*.ts",
"packages/**/*.ts"
"packages/**/*.ts",
"karma.conf.ts",
"karma.setup.ts"
],
"exclude": [
"**/node_modules"
Expand Down
26 changes: 26 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8742,6 +8742,13 @@
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31"
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==

"@playwright/test@^1.49.0":
version "1.49.0"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.49.0.tgz#74227385b58317ee076b86b56d0e1e1b25cff01e"
integrity sha512-DMulbwQURa8rNIQrf94+jPJQ4FmOVdpE5ZppRNvWVjvhC+6sOeo28r8MgIpQRYouXRtt/FCCXU7zn20jnHR4Qw==
dependencies:
playwright "1.49.0"

"@pollyjs/adapter-node-http@^6.0.6":
version "6.0.6"
resolved "https://registry.yarnpkg.com/@pollyjs/adapter-node-http/-/adapter-node-http-6.0.6.tgz#7122765604e3dfdd6d68bced8a89c7966d49d710"
Expand Down Expand Up @@ -13217,6 +13224,11 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

[email protected]:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

fsevents@^2.3.2, fsevents@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
Expand Down Expand Up @@ -17312,6 +17324,20 @@ pkg-types@^1.0.3, pkg-types@^1.1.1:
mlly "^1.7.0"
pathe "^1.1.2"

[email protected]:
version "1.49.0"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.49.0.tgz#8e69ffed3f41855b854982f3632f2922c890afcb"
integrity sha512-R+3KKTQF3npy5GTiKH/T+kdhoJfJojjHESR1YEWhYuEKRVfVaxH3+4+GvXE5xyCngCxhxnykk0Vlah9v8fs3jA==

[email protected]:
version "1.49.0"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.49.0.tgz#df6b9e05423377a99658202844a294a8afb95d0a"
integrity sha512-eKpmys0UFDnfNb3vfsf8Vx2LEOtflgRebl0Im2eQQnYMA4Aqd+Zw8bEOB+7ZKvN76901mRnqdsiOGKxzVTbi7A==
dependencies:
playwright-core "1.49.0"
optionalDependencies:
fsevents "2.3.2"

please-upgrade-node@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942"
Expand Down

0 comments on commit ec240db

Please sign in to comment.