-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathintegration.test.ts
121 lines (115 loc) · 3.5 KB
/
integration.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import prettier from "@prettier/sync";
import { prepareOptions } from "bingo";
import { intake, IntakeDirectory } from "bingo-fs";
import { producePreset } from "bingo-stratum";
import { diffCreatedDirectory } from "bingo-testers";
import { expect, test } from "vitest";
import {
base,
BaseOptions,
blockAreTheTypesWrong,
blockCodecov,
blockCSpell,
blockESLint,
blockKnip,
blockTemplatedWith,
blockTSup,
presets,
} from "./index.js";
// This test checks the Bingo production using options inferred from disk,
// along with some explicit addons and blocks specified.
// It ensures that result has no differences from the actual files on disk.
//
// If the test fails, it's most likely due to a block being changed without the
// corresponding file(s) on disk also being changed.
// You may need to manually update files on disk to match the block's output.
//
// The next most likely culprit for failures is changing file contents that are
// specified by the addons mentioned in the producePreset() call below.
// For now, if you change the output on disk, you'll need to manually update here too.
// TODO: Eventually the create engine will be able to infer them:
// https://github.com/JoshuaKGoldberg/bingo/issues/128
//
// For example, if you change blockTypeScript's target from "ES2022 to "ES2023",
// you'll also need to update the ./tsconfig.json on disk in the same way.
test("Producing the everything preset matches the files in this repository", async () => {
const actual = (await intake(".", {
exclude: /node_modules|^\.git$/,
})) as IntakeDirectory;
const created = producePreset(presets.everything, {
options: (await prepareOptions(base)) as BaseOptions,
refinements: {
addons: [
blockCodecov({
env: {
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}",
},
}),
blockCSpell({
words: [
"Anson",
"apexskier",
"attw",
"boop",
"dbaeumer",
"infile",
"joshuakgoldberg",
"markdownlintignore",
"mshick",
"mtfoley",
"npmjs",
"stefanzweifel",
],
}),
blockESLint({
explanations: [
`👋 Hi! This ESLint configuration contains a lot more stuff than many repos'!
You can read from it to see all sorts of linting goodness, but don't worry -
it's not something you need to exhaustively understand immediately. 💙
If you're interested in learning more, see the 'getting started' docs on:
- ESLint: https://eslint.org
- typescript-eslint: https://typescript-eslint.io`,
],
rules: [
{
comment:
"These on-by-default rules work well for this repo if configured",
entries: {
"@typescript-eslint/prefer-nullish-coalescing": [
"error",
{ ignorePrimitives: true },
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{ allowBoolean: true, allowNullish: true, allowNumber: true },
],
},
},
],
}),
blockKnip({
ignoreDependencies: [
"all-contributors-cli",
"cspell-populate-words",
"remove-dependencies",
"trash-cli",
],
}),
blockTSup({
runArgs: ["--version"],
}),
],
blocks: {
add: [blockAreTheTypesWrong],
exclude: [blockTemplatedWith],
},
},
});
const processText = (text: string, filePath: string) =>
/all-contributorsrc|js|md|ts|yml/.test(filePath)
? prettier.format(text, { filepath: filePath, useTabs: true })
: text;
expect(
diffCreatedDirectory(actual, created.files, processText),
).toBeUndefined();
});