Skip to content

Commit

Permalink
Merge branch 'master' into Pinned-Dependencies-GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
pmvald committed Feb 5, 2024
2 parents 172f7ae + 0bffce2 commit 0b96f86
Show file tree
Hide file tree
Showing 15 changed files with 10,063 additions and 6,465 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,25 @@
## [6.4.2](https://github.com/karma-runner/karma/compare/v6.4.1...v6.4.2) (2023-04-21)


### Bug Fixes

* few typos ([c6a4271](https://github.com/karma-runner/karma/commit/c6a42710b40e81269f1e6c5d5bb55d01188a8872))

## [6.4.1](https://github.com/karma-runner/karma/compare/v6.4.0...v6.4.1) (2022-09-19)


### Bug Fixes

* pass integrity value ([63d86be](https://github.com/karma-runner/karma/commit/63d86befd3431fe8e1500e22f4f115a3762d000a))

# [6.4.0](https://github.com/karma-runner/karma/compare/v6.3.20...v6.4.0) (2022-06-14)


### Features

* support SRI verification of link tags ([dc51a2e](https://github.com/karma-runner/karma/commit/dc51a2e0e9b9805f7740f52fde01bcd20adc2dfc))
* support SRI verification of script tags ([6a54b1c](https://github.com/karma-runner/karma/commit/6a54b1c2a1df8214c470b8a5cc8036912874637e))

## [6.3.20](https://github.com/karma-runner/karma/compare/v6.3.19...v6.3.20) (2022-05-13)


Expand Down
16 changes: 15 additions & 1 deletion README.md
@@ -1,14 +1,28 @@
# Karma
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/karma-runner/karma) [![npm version](https://img.shields.io/npm/v/karma.svg?style=flat-square)](https://www.npmjs.com/package/karma) [![npm downloads](https://img.shields.io/npm/dm/karma.svg?style=flat-square)](https://npmcharts.com/compare/karma?minimal=true)

[![Code Climate](https://img.shields.io/codeclimate/github/karma-runner/karma.svg?style=flat-square)](https://codeclimate.com/github/karma-runner/karma) [![PRs Welcome](https://img.shields.io/badge/prs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com/) [![Dependency Status](https://img.shields.io/david/karma-runner/karma.svg?style=flat-square)](https://david-dm.org/karma-runner/karma) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma.svg?style=flat-square)](https://david-dm.org/karma-runner/karma#info=devDependencies) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Code Climate](https://img.shields.io/codeclimate/maintainability/karma-runner/karma)](https://codeclimate.com/github/karma-runner/karma) [![PRs Welcome](https://img.shields.io/badge/prs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com/) [![Dependency Status](https://img.shields.io/david/karma-runner/karma.svg?style=flat-square)](https://david-dm.org/karma-runner/karma) [![devDependency Status](https://img.shields.io/david/dev/karma-runner/karma.svg?style=flat-square)](https://david-dm.org/karma-runner/karma#info=devDependencies) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

A simple tool that allows you to execute JavaScript code in multiple
_real_ browsers.

> The main purpose of Karma is to make your test-driven development easy,
> fast, and fun.
## Karma is deprecated and is not accepting new features or general bug fixes.

The web testing space has evolved significantly in the [10+ years](https://testing.googleblog.com/2012/11/testacular-spectacular-test-runner-for.html) since Karma's creation. The web landscape looks very different today and new patterns and tools have emerged in the ecosystem. New test runners offer more performant alternatives, and Karma no longer provides clear unique value.

Based on the current state of the web testing ecosystem, we have made the hard decision to deprecate Karma.

We know Karma is used particularly commonly in the Angular ecosystem, so Angular is adding [Jest](https://jestjs.io/) and [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) support to provide a migration path off of Karma. See the [Angular blog](https://blog.angular.io/moving-angular-cli-to-jest-and-web-test-runner-ef85ef69ceca) for more details.

Critical security issues in Karma will still be triaged and fixed as necessary. This will continue until 12 months after Angular CLI's Web Test Runner support is marked stable.

For those outside Angular looking to migrate off Karma, both [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) and [`jasmine-browser-runner`](https://github.com/jasmine/jasmine-browser-runner) provide browser-based unit testing solutions which can be used as a direct alternative. [Jest](https://jestjs.io/) and [Vitest](https://vitest.dev/) also provide Node-based alternatives.

It has been incredible to see Karma's impact on the web testing ecosystem and we greatly appreciate the support of everyone who contributed to an awesome community. Keep testing. ✅


## Help and Support

Expand Down
2 changes: 1 addition & 1 deletion context/main.js
Expand Up @@ -12,7 +12,7 @@ var callParentKarmaMethod = ContextKarma.getDirectCallParentKarmaMethod(parentWi
// DEV: We avoid using this in Internet Explorer as they only support strings
// https://caniuse.com/?search=postmessage
var haveParentAccess = false
try { haveParentAccess = !!parentWindow.window } catch (err) { /* Ignore errors (likely permisison errors) */ }
try { haveParentAccess = !!parentWindow.window } catch (err) { /* Ignore errors (likely permission errors) */ }
if (!haveParentAccess) {
callParentKarmaMethod = ContextKarma.getPostMessageCallParentKarmaMethod(parentWindow)
}
Expand Down
7 changes: 6 additions & 1 deletion docs/config/02-files.md
Expand Up @@ -15,7 +15,7 @@ The `files` array determines which files are included in the browser, watched, a
* **Default.** Will attempt to determine type based on file extension. If that fails, defaults to `js`.
* **Possible Values:**
* `css` - Include using `<link rel="stylesheet">` tag.
* `html` - Include using [HTML Imports](https://developer.mozilla.org/en-US/docs/Web/Web_Components/HTML_Imports). Note that this feature is obsolete and does not work in the modern browsers.
* `html` - Include using [HTML Imports](https://developer.mozilla.org/en-US/docs/Web/Web_Components/HTML_Imports). Note that this feature is obsolete and does not work in the modern browsers.
* `js` - Include using `<script></script>` tag.
* `module` - Include using `<script type="module"></script>` tag.
* `dom` - Inline content of the file in the page. This can be used, for example, to test components combining HTML and JS.
Expand Down Expand Up @@ -54,6 +54,11 @@ The `files` array determines which files are included in the browser, watched, a
* **Default.** `false`
* **Description.** Should the files be served from disk on each request by Karma's webserver?

### `integrity`
* **Type.** String
* **Default.** `undefined`
* **Description.** Set the `integrity` HTML attribute value to the `<script>` or the `<link>` tag loading the resource that matches the given pattern if the pattern is an absolute URL.

## Pattern matching and `basePath`
- All of the relative patterns will get resolved using the `basePath` first.
- If the `basePath` is a relative path, it gets resolved to the
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/04-public-api.md
Expand Up @@ -288,7 +288,7 @@ const karmaConfig = cfg.parseConfig(
```

The new behavior in the future will involve throwing exceptions instead of
exiting the process and aynchronous config files will be supported through the
exiting the process and asynchronous config files will be supported through the
use of promises.

##### New Behavior
Expand Down
9 changes: 5 additions & 4 deletions lib/config.js
Expand Up @@ -32,7 +32,7 @@ try {
} catch {}

class Pattern {
constructor (pattern, served, included, watched, nocache, type, isBinary) {
constructor (pattern, served, included, watched, nocache, type, isBinary, integrity) {
this.pattern = pattern
this.served = helper.isDefined(served) ? served : true
this.included = helper.isDefined(included) ? included : true
Expand All @@ -41,6 +41,7 @@ class Pattern {
this.weight = helper.mmPatternWeight(pattern)
this.type = type
this.isBinary = isBinary
this.integrity = integrity
}

compare (other) {
Expand All @@ -49,8 +50,8 @@ class Pattern {
}

class UrlPattern extends Pattern {
constructor (url, type) {
super(url, false, true, false, false, type)
constructor (url, type, integrity) {
super(url, false, true, false, false, type, undefined, integrity)
}
}

Expand All @@ -61,7 +62,7 @@ function createPatternObject (pattern) {
: new Pattern(pattern)
} else if (helper.isObject(pattern) && pattern.pattern && helper.isString(pattern.pattern)) {
return helper.isUrlAbsolute(pattern.pattern)
? new UrlPattern(pattern.pattern, pattern.type)
? new UrlPattern(pattern.pattern, pattern.type, pattern.integrity)
: new Pattern(pattern.pattern, pattern.served, pattern.included, pattern.watched, pattern.nocache, pattern.type)
} else {
log.warn(`Invalid pattern ${pattern}!\n\tExpected string or object with "pattern" property.`)
Expand Down
4 changes: 2 additions & 2 deletions lib/file-list.js
Expand Up @@ -62,9 +62,9 @@ class FileList {

let lastCompletedRefresh = this._refreshing
lastCompletedRefresh = Promise.all(
this._patterns.map(async ({ pattern, type, nocache, isBinary }) => {
this._patterns.map(async ({ pattern, type, nocache, isBinary, integrity }) => {
if (helper.isUrlAbsolute(pattern)) {
this.buckets.set(pattern, [new Url(pattern, type)])
this.buckets.set(pattern, [new Url(pattern, type, integrity)])
return
}

Expand Down
4 changes: 3 additions & 1 deletion lib/file.js
Expand Up @@ -6,7 +6,7 @@ const path = require('path')
* File object used for tracking files in `file-list.js`.
*/
class File {
constructor (path, mtime, doNotCache, type, isBinary) {
constructor (path, mtime, doNotCache, type, isBinary, integrity) {
// used for serving (processed path, eg some/file.coffee -> some/file.coffee.js)
this.path = path

Expand All @@ -29,6 +29,8 @@ class File {

// Tri state: null means probe file for binary.
this.isBinary = isBinary === undefined ? null : isBinary

this.integrity = integrity
}

/**
Expand Down
11 changes: 6 additions & 5 deletions lib/middleware/karma.js
Expand Up @@ -182,19 +182,20 @@ function createKarmaMiddleware (
}
}

const integrityAttribute = file.integrity ? ` integrity="${file.integrity}"` : ''
const crossOriginAttribute = includeCrossOriginAttribute ? ' crossorigin="anonymous"' : ''
if (fileType === 'css') {
scriptTags.push(`<link type="text/css" href="${filePath}" rel="stylesheet">`)
scriptTags.push(`<link type="text/css" href="${filePath}" rel="stylesheet"${integrityAttribute}${crossOriginAttribute}>`)
} else if (fileType === 'dom') {
scriptTags.push(file.content)
} else if (fileType === 'html') {
scriptTags.push(`<link href="${filePath}" rel="import">`)
scriptTags.push(`<link href="${filePath}" rel="import"${integrityAttribute}${crossOriginAttribute}>`)
} else {
const scriptType = (SCRIPT_TYPE[fileType] || 'text/javascript')
const crossOriginAttribute = includeCrossOriginAttribute ? 'crossorigin="anonymous"' : ''
if (fileType === 'module') {
scriptTags.push(`<script onerror="throw 'Error loading ${filePath}'" type="${scriptType}" src="${filePath}" ${crossOriginAttribute}></script>`)
scriptTags.push(`<script onerror="throw 'Error loading ${filePath}'" type="${scriptType}" src="${filePath}"${integrityAttribute}${crossOriginAttribute}></script>`)
} else {
scriptTags.push(`<script type="${scriptType}" src="${filePath}" ${crossOriginAttribute}></script>`)
scriptTags.push(`<script type="${scriptType}" src="${filePath}"${integrityAttribute}${crossOriginAttribute}></script>`)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/url.js
Expand Up @@ -7,10 +7,11 @@ const { URL } = require('url')
* Url object used for tracking files in `file-list.js`.
*/
class Url {
constructor (path, type) {
constructor (path, type, integrity) {
this.path = path
this.originalPath = path
this.type = type
this.integrity = integrity
this.isUrl = true
}

Expand Down

0 comments on commit 0b96f86

Please sign in to comment.