Skip to content

Commit

Permalink
docs(devs-infra): add example transform match file regex (#3834)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Sep 25, 2022
1 parent afc6a94 commit 12a90d3
Show file tree
Hide file tree
Showing 18 changed files with 336 additions and 112 deletions.
12 changes: 9 additions & 3 deletions website/docs/getting-started/options.md
Expand Up @@ -13,7 +13,9 @@ or through a `jest.config.js`, or `jest.config.ts` file.
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
// ts-jest configuration goes here
Expand All @@ -29,7 +31,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
// ts-jest configuration goes here
Expand All @@ -44,7 +48,9 @@ const jestConfig: JestConfigWithTsJest = {
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
// ts-jest configuration goes here
Expand Down
24 changes: 18 additions & 6 deletions website/docs/getting-started/options/astTransformers.md
Expand Up @@ -21,7 +21,9 @@ The option is `astTransformers` and it allows ones to specify which 3 types of T
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
astTransformers: {
Expand All @@ -39,7 +41,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
astTransformers: {
Expand All @@ -58,7 +62,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"astTransformers": {
Expand All @@ -78,7 +84,9 @@ export default jestConfig
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
astTransformers: {
Expand All @@ -101,7 +109,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
astTransformers: {
Expand All @@ -125,7 +135,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"astTransformers": {
Expand Down
44 changes: 33 additions & 11 deletions website/docs/getting-started/options/babelConfig.md
Expand Up @@ -19,7 +19,9 @@ The option is `babelConfig` and it works pretty much as the `tsconfig` option, e
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
babelConfig: true,
Expand All @@ -35,7 +37,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
babelConfig: true,
Expand All @@ -53,7 +57,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"babelConfig": true
Expand All @@ -73,7 +79,9 @@ The path should be relative to the current working directory where you start Jes
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
babelConfig: 'babelrc.test.js',
Expand All @@ -89,7 +97,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
babelConfig: 'babelrc.test.js',
Expand All @@ -106,7 +116,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"babelConfig": "babelrc.test.js"
Expand All @@ -124,7 +136,9 @@ or importing directly the config file:
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
babelConfig: require('./babelrc.test.js'),
Expand All @@ -141,7 +155,9 @@ import babelConfig from './babelrc.test.js'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
babelConfig,
Expand All @@ -162,7 +178,9 @@ Refer to the [Babel options](https://babeljs.io/docs/en/next/options) to know wh
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
babelConfig: {
Expand All @@ -181,7 +199,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
babelConfig: {
Expand All @@ -201,7 +221,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"babelConfig": {
Expand Down
12 changes: 9 additions & 3 deletions website/docs/getting-started/options/compiler.md
Expand Up @@ -16,7 +16,9 @@ If you use a custom compiler, such as `ttypescript`, make sure its API is the sa
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
compiler: 'ttypescript',
Expand All @@ -32,7 +34,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
compiler: 'ttypescript',
Expand All @@ -49,7 +53,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"compiler": "ttypescript"
Expand Down
48 changes: 36 additions & 12 deletions website/docs/getting-started/options/diagnostics.md
Expand Up @@ -36,7 +36,9 @@ The `diagnostics` option's value can also accept an object for more advanced con
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: false,
Expand All @@ -52,7 +54,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: false,
Expand All @@ -69,7 +73,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"diagnostics": false
Expand All @@ -91,7 +97,9 @@ Assuming all your test files ends with `.spec.ts` or `.test.ts`, using the follo
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: {
Expand All @@ -109,7 +117,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: {
Expand All @@ -129,7 +139,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"diagnostics": {
Expand All @@ -151,7 +163,9 @@ While some diagnostics are stop-blockers for the compilation, most of them are n
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: {
Expand All @@ -169,7 +183,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: {
Expand All @@ -188,7 +204,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"diagnostics": {
Expand All @@ -215,7 +233,9 @@ All TypeScript error codes can be found [there](https://github.com/Microsoft/Typ
module.exports = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: {
Expand All @@ -233,7 +253,9 @@ import type { JestConfigWithTsJest } from 'ts-jest'
const jestConfig: JestConfigWithTsJest = {
// [...]
transform: {
'<regex_match_files>': [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: {
Expand All @@ -252,7 +274,9 @@ export default jestConfig
// [...]
"jest": {
"transform": {
"<regex_match_files>": [
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
"^.+\\.tsx?$": [
"ts-jest",
{
"diagnostics": {
Expand Down

0 comments on commit 12a90d3

Please sign in to comment.