Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest compliance #46

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 60 additions & 12 deletions src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ describe('main', () => {
JSON.stringify({
packageManager: 'yarn',
engines: { node: 'test' },
devDependencies: { eslint: '1.1.0' },
devDependencies: {
eslint: '1.1.0',
jest: '1.0.0',
'jest-it-up': '1.0.0',
},
scripts: {
test: 'test script',
'test:watch': 'test watch script',
},
}),
);
await writeFile(
Expand All @@ -84,6 +92,10 @@ describe('main', () => {
path.join(repository.directoryPath, '.nvmrc'),
'content for .nvmrc',
);
await writeFile(
path.join(repository.directoryPath, 'jest.config.js'),
'content for jest.config.js',
);
}
const outputLogger = new FakeOutputLogger();

Expand All @@ -108,15 +120,18 @@ repo-1
- Does the \`packageManager\` field in \`package.json\` conform? ✅
- Does the \`engines.node\` field in \`package.json\` conform? ✅
- Do the lint-related \`devDependencies\` in \`package.json\` conform? ✅
- Do the jest-related \`devDependencies\` in \`package.json\` conform? ✅
- Do the test-related \`scripts\` in \`package.json\` conform? ✅
- Is \`README.md\` present? ✅
- Does the README conform by recommending the correct Yarn version to install? ✅
- Does the README conform by recommending node install from nodejs.org? ✅
- Are all of the files for Yarn Modern present, and do they conform? ✅
- Does the README conform by recommending the correct Yarn version to install? ✅
- Does the \`src/\` directory exist? ✅
- Is \`.nvmrc\` present, and does it conform? ✅
- Is \`jest.config.js\` present, and does it conform? ✅

Results: 12 passed, 0 failed, 12 total
Results: 15 passed, 0 failed, 15 total
Elapsed time: 0 ms


Expand All @@ -128,15 +143,18 @@ repo-2
- Does the \`packageManager\` field in \`package.json\` conform? ✅
- Does the \`engines.node\` field in \`package.json\` conform? ✅
- Do the lint-related \`devDependencies\` in \`package.json\` conform? ✅
- Do the jest-related \`devDependencies\` in \`package.json\` conform? ✅
- Do the test-related \`scripts\` in \`package.json\` conform? ✅
- Is \`README.md\` present? ✅
- Does the README conform by recommending the correct Yarn version to install? ✅
- Does the README conform by recommending node install from nodejs.org? ✅
- Are all of the files for Yarn Modern present, and do they conform? ✅
- Does the README conform by recommending the correct Yarn version to install? ✅
- Does the \`src/\` directory exist? ✅
- Is \`.nvmrc\` present, and does it conform? ✅
- Is \`jest.config.js\` present, and does it conform? ✅

Results: 12 passed, 0 failed, 12 total
Results: 15 passed, 0 failed, 15 total
Elapsed time: 0 ms

`,
Expand Down Expand Up @@ -195,8 +213,10 @@ repo-1
- \`src/\` does not exist in this project.
- Is \`.nvmrc\` present, and does it conform? ❌
- \`.nvmrc\` does not exist in this project.
- Is \`jest.config.js\` present, and does it conform? ❌
- \`jest.config.js\` does not exist in this project.

Results: 0 passed, 6 failed, 6 total
Results: 0 passed, 7 failed, 7 total
Elapsed time: 0 ms


Expand All @@ -217,8 +237,10 @@ repo-2
- \`src/\` does not exist in this project.
- Is \`.nvmrc\` present, and does it conform? ❌
- \`.nvmrc\` does not exist in this project.
- Is \`jest.config.js\` present, and does it conform? ❌
- \`jest.config.js\` does not exist in this project.

Results: 0 passed, 6 failed, 6 total
Results: 0 passed, 7 failed, 7 total
Elapsed time: 0 ms

`,
Expand Down Expand Up @@ -283,8 +305,10 @@ repo-2
- \`src/\` does not exist in this project.
- Is \`.nvmrc\` present, and does it conform? ❌
- \`.nvmrc\` does not exist in this project.
- Is \`jest.config.js\` present, and does it conform? ❌
- \`jest.config.js\` does not exist in this project.

Results: 1 passed, 5 failed, 6 total
Results: 1 passed, 6 failed, 7 total
Elapsed time: 0 ms

`.trimStart(),
Expand Down Expand Up @@ -340,7 +364,15 @@ Elapsed time: 0 ms
JSON.stringify({
packageManager: 'yarn',
engines: { node: 'test' },
devDependencies: { eslint: '1.1.0' },
devDependencies: {
eslint: '1.1.0',
jest: '1.0.0',
'jest-it-up': '1.0.0',
},
scripts: {
test: 'test script',
'test:watch': 'test watch script',
},
}),
);
await writeFile(
Expand All @@ -351,6 +383,10 @@ Elapsed time: 0 ms
path.join(repository.directoryPath, '.nvmrc'),
'content for .nvmrc',
);
await writeFile(
path.join(repository.directoryPath, 'jest.config.js'),
'content for jest.config.js',
);
}
const outputLogger = new FakeOutputLogger();

Expand All @@ -375,15 +411,18 @@ repo-1
- Does the \`packageManager\` field in \`package.json\` conform? ✅
- Does the \`engines.node\` field in \`package.json\` conform? ✅
- Do the lint-related \`devDependencies\` in \`package.json\` conform? ✅
- Do the jest-related \`devDependencies\` in \`package.json\` conform? ✅
- Do the test-related \`scripts\` in \`package.json\` conform? ✅
- Is \`README.md\` present? ✅
- Does the README conform by recommending the correct Yarn version to install? ✅
- Does the README conform by recommending node install from nodejs.org? ✅
- Are all of the files for Yarn Modern present, and do they conform? ✅
- Does the README conform by recommending the correct Yarn version to install? ✅
- Does the \`src/\` directory exist? ✅
- Is \`.nvmrc\` present, and does it conform? ✅
- Is \`jest.config.js\` present, and does it conform? ✅

Results: 12 passed, 0 failed, 12 total
Results: 15 passed, 0 failed, 15 total
Elapsed time: 0 ms


Expand All @@ -395,15 +434,18 @@ repo-2
- Does the \`packageManager\` field in \`package.json\` conform? ✅
- Does the \`engines.node\` field in \`package.json\` conform? ✅
- Do the lint-related \`devDependencies\` in \`package.json\` conform? ✅
- Do the jest-related \`devDependencies\` in \`package.json\` conform? ✅
- Do the test-related \`scripts\` in \`package.json\` conform? ✅
- Is \`README.md\` present? ✅
- Does the README conform by recommending the correct Yarn version to install? ✅
- Does the README conform by recommending node install from nodejs.org? ✅
- Are all of the files for Yarn Modern present, and do they conform? ✅
- Does the README conform by recommending the correct Yarn version to install? ✅
- Does the \`src/\` directory exist? ✅
- Is \`.nvmrc\` present, and does it conform? ✅
- Is \`jest.config.js\` present, and does it conform? ✅

Results: 12 passed, 0 failed, 12 total
Results: 15 passed, 0 failed, 15 total
Elapsed time: 0 ms

`,
Expand Down Expand Up @@ -462,8 +504,10 @@ repo-1
- \`src/\` does not exist in this project.
- Is \`.nvmrc\` present, and does it conform? ❌
- \`.nvmrc\` does not exist in this project.
- Is \`jest.config.js\` present, and does it conform? ❌
- \`jest.config.js\` does not exist in this project.

Results: 0 passed, 6 failed, 6 total
Results: 0 passed, 7 failed, 7 total
Elapsed time: 0 ms


Expand All @@ -484,8 +528,10 @@ repo-2
- \`src/\` does not exist in this project.
- Is \`.nvmrc\` present, and does it conform? ❌
- \`.nvmrc\` does not exist in this project.
- Is \`jest.config.js\` present, and does it conform? ❌
- \`jest.config.js\` does not exist in this project.

Results: 0 passed, 6 failed, 6 total
Results: 0 passed, 7 failed, 7 total
Elapsed time: 0 ms

`,
Expand Down Expand Up @@ -549,8 +595,10 @@ repo-2
- \`src/\` does not exist in this project.
- Is \`.nvmrc\` present, and does it conform? ❌
- \`.nvmrc\` does not exist in this project.
- Is \`jest.config.js\` present, and does it conform? ❌
- \`jest.config.js\` does not exist in this project.

Results: 1 passed, 5 failed, 6 total
Results: 1 passed, 6 failed, 7 total
Elapsed time: 0 ms

`,
Expand Down
6 changes: 6 additions & 0 deletions src/rules/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import allYarnModernFilesConform from './all-yarn-modern-files-conform';
import classicYarnConfigFileAbsent from './classic-yarn-config-file-absent';
import packageEnginesNodeFieldConforms from './package-engines-node-field-conforms';
import packageJestDependenciesConform from './package-jest-dependencies-conform';
import packageLintDependenciesConform from './package-lint-dependencies-conform';
import packagePackageManagerFieldConforms from './package-package-manager-field-conforms';
import packageTestScriptsConform from './package-test-scripts-conform';
import readmeListsCorrectYarnVersion from './readme-lists-correct-yarn-version';
import readmeListsNodejsWebsite from './readme-recommends-node-install';
import requireJestConfig from './require-jest-config';
import requireNvmrc from './require-nvmrc';
import requireReadme from './require-readme';
import requireSourceDirectory from './require-source-directory';
Expand All @@ -22,4 +25,7 @@ export const rules = [
packageEnginesNodeFieldConforms,
readmeListsNodejsWebsite,
packageLintDependenciesConform,
packageJestDependenciesConform,
requireJestConfig,
packageTestScriptsConform,
] as const;
4 changes: 4 additions & 0 deletions src/rules/package-engines-node-field-conforms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('Rule: package-engines-node-field-conforms', () => {
packageManager: 'a',
engines: { node: 'test' },
devDependencies: { eslint: '1.0.0' },
scripts: { test: 'jest && jest-it-up' },
}),
);
const project = buildMetaMaskRepository({
Expand All @@ -30,6 +31,7 @@ describe('Rule: package-engines-node-field-conforms', () => {
packageManager: 'a',
engines: { node: 'test' },
devDependencies: { eslint: '1.0.0' },
scripts: { test: 'jest && jest-it-up' },
}),
);

Expand Down Expand Up @@ -58,6 +60,7 @@ describe('Rule: package-engines-node-field-conforms', () => {
packageManager: 'a',
engines: { node: 'test1' },
devDependencies: { eslint: '1.0.0' },
scripts: { test: 'jest && jest-it-up' },
}),
);
const project = buildMetaMaskRepository({
Expand All @@ -70,6 +73,7 @@ describe('Rule: package-engines-node-field-conforms', () => {
packageManager: 'a',
engines: { node: 'test2' },
devDependencies: { eslint: '1.0.0' },
scripts: { test: 'jest && jest-it-up' },
}),
);

Expand Down
Loading
Loading