-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into task-1258-form-disclaimer-broken
- Loading branch information
Showing
208 changed files
with
5,568 additions
and
4,406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const coffeescript = require('coffeescript'); | ||
const createCacheKeyFunction = require('@jest/create-cache-key-function').default; | ||
/** | ||
* @typedef {import('@jest/transform').SyncTransformer} SyncTransformer | ||
* @typedef {import('@jest/transform').TransformedSource} TransformedSource | ||
*/ | ||
|
||
/** | ||
* Transform CoffeeScript files for Jest | ||
* See: https://jestjs.io/docs/code-transformation | ||
* | ||
* @implements { SyncTransformer } | ||
*/ | ||
module.exports = { | ||
/** | ||
* Process coffee files | ||
* | ||
* @param {string} sourceText | ||
* @param {string} filename | ||
* @returns {TransformedSource} | ||
*/ | ||
process(sourceText, filename) { | ||
const {js, sourceMap, v3SourceMap } = coffeescript.compile( | ||
sourceText, | ||
// ☕ CoffeeScript 1.12.7 compiler options | ||
{ | ||
// 📜 For source maps | ||
filename, | ||
sourceMap: true, | ||
|
||
// 📦 Same default as coffee-loader | ||
bare: true, | ||
} | ||
); | ||
return { | ||
code: js, | ||
map: JSON.parse(v3SourceMap), | ||
}; | ||
}, | ||
|
||
getCacheKey: createCacheKeyFunction( | ||
[__filename, require.resolve('coffeescript')], | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import chai from 'chai'; | ||
import $ from 'jquery'; | ||
|
||
// Polyfill global fetch (for Node 20 and older) | ||
import 'whatwg-fetch'; | ||
|
||
// Add global t() mock (see /static/js/global_t.js) | ||
global.t = (str: string) => str; | ||
|
||
// @ts-expect-error: ℹ️ Add chai global for BDD-style tests | ||
global.chai = chai; | ||
|
||
// @ts-expect-error: ℹ️ Use chai's version of `expect` | ||
global.expect = chai.expect; | ||
|
||
// @ts-expect-error: ℹ️ Add jQuery globals for xlform code | ||
global.jQuery = global.$ = $; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type {Config} from 'jest'; | ||
import {defaults} from 'jest-config'; | ||
|
||
// Config to run ☕ unit tests using the Jest runner | ||
// | ||
// To run the unit tests: 🏃 | ||
// | ||
// npx jest --config ./jsapp/jest/unit.config.ts | ||
// | ||
|
||
const config: Config = { | ||
// Naming convention (*.tests.*) | ||
testMatch: ['**/?(*.)+(tests).(js|jsx|ts|tsx|es6|coffee)'], | ||
|
||
// Where to find tests. <rootDir> = 'kpi/jsapp/jest' | ||
roots: [ | ||
'<rootDir>/../js/', // unit tests 🛠️ 'jsapp/js/**/*.tests.{ts,es6}' | ||
'<rootDir>/../../test/', // xlform/coffee ☕ 'test/**/*.tests.coffee' | ||
], | ||
|
||
// Where to resolve module imports | ||
moduleNameMapper: { | ||
// ℹ️ same aliases as in webpack.common.js (module.resolve.alias) | ||
'^jsapp/(.+)$': '<rootDir>/../$1', // 📁 'jsapp/*' | ||
'^js/(.*)$': '<rootDir>/../js/$1', // 📁 'js/*' | ||
'^test/(.*)$': '<rootDir>/../../test/$1', // 📁 'test/*' | ||
'^utils$': '<rootDir>/../js/utils', // 📄 'utils' | ||
// 🎨 mock all CSS modules imported (styles.root = 'root') | ||
'\\.(css|scss)$': 'identity-obj-proxy', | ||
}, | ||
|
||
// Extensions to try in order (for import statements with no extension) | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'es6', 'coffee'], | ||
|
||
// Transformers (SWC for JS/TS, CoffeeScript for .coffee) | ||
transform: { | ||
'^.+\\.(js|jsx|ts|tsx|es6)$': '@swc/jest', | ||
'^.+\\.coffee$': '<rootDir>/coffeeTransformer.js', | ||
}, | ||
|
||
// Exclude these files, even if they contain tests | ||
testPathIgnorePatterns: [ | ||
'test/xlform/integration.tests.coffee$', // 📄 skipped in `ee98aebe631b` | ||
...defaults.testPathIgnorePatterns, // 📦 exclude '/node_modules/' | ||
], | ||
|
||
// Set up test environment | ||
testEnvironment: 'jsdom', | ||
|
||
// Make Chai and jQuery globals available in the test environment | ||
setupFilesAfterEnv: ['<rootDir>/setupUnitTest.ts'], | ||
|
||
// Appearance options (for console output) | ||
verbose: true, | ||
displayName: {name: 'UNIT', color: 'black'}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.