Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/solutions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
run: ./scripts/copy-solutions.sh
shell: bash
- name: Run changed solutions in project directories
if: ${{ steps.changed-files.outputs.all_changed_files != '' }}
run: npx zx ./scripts/changed-solutions.mjs "test:solutions" ${{ steps.changed-files.outputs.all_changed_files }}
if: ${{ steps.changed-files.outputs.all_modified_files != '' }}
run: npx zx ./scripts/changed-solutions.mjs "test:solutions" ${{ steps.changed-files.outputs.all_modified_files }}
shell: bash
- name: Run all solutions tests
if: ${{ steps.changed-files.outputs.all_changed_files == '' }}
if: ${{ steps.changed-files.outputs.all_modified_files == '' }}
run: ./scripts/check-solutions.sh "test:solutions"
shell: bash
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
run: ./scripts/copy-solutions.sh
shell: bash
- name: Run test in project directories
if: ${{ steps.changed-files.outputs.all_changed_files != '' }}
run: npx zx ./scripts/changed-solutions.mjs test ${{ steps.changed-files.outputs.all_changed_files }}
if: ${{ steps.changed-files.outputs.all_modified_files != '' }}
run: npx zx ./scripts/changed-solutions.mjs test ${{ steps.changed-files.outputs.all_modified_files }}
shell: bash
- name: Run test in all project directories
if: ${{ steps.changed-files.outputs.all_changed_files == '' }}
if: ${{ steps.changed-files.outputs.all_modified_files == '' }}
run: ./scripts/check-solutions.sh "test"
shell: bash
6 changes: 3 additions & 3 deletions .github/workflows/tsc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
run: ./scripts/copy-solutions.sh
shell: bash
- name: Run tsc in project directories
if: ${{ steps.changed-files.outputs.all_changed_files != '' }}
run: npx zx ./scripts/changed-solutions.mjs tsc ${{ steps.changed-files.outputs.all_changed_files }}
if: ${{ steps.changed-files.outputs.all_modified_files != '' }}
run: npx zx ./scripts/changed-solutions.mjs tsc ${{ steps.changed-files.outputs.all_modified_files }}
shell: bash
- name: Run tsc in all project directories
if: ${{ steps.changed-files.outputs.all_changed_files == '' }}
if: ${{ steps.changed-files.outputs.all_modified_files == '' }}
run: ./scripts/check-solutions.sh "tsc"
shell: bash
32 changes: 32 additions & 0 deletions test/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ for (const chapterSlug of fs.readdirSync("projects")) {
testAppetizerProject();
}

function projectUsesJest() {
const packageData = readFileAsJSON(
`${chapterDirectory}/${projectSlug}/package.json`,
) as PackageData;

return packageData.scripts.test === "jest";
}

function testContainsTestFile(directorySlug: string) {
test("test file", () => {
const directoryContents = fs.readdirSync(
`${chapterDirectory}/${projectSlug}/${directorySlug}`,
);

expect(
directoryContents.filter((fileName) =>
fileName.includes(".test."),
),
).not.toEqual([]);
});
}

function testAppetizerProject() {
const stepSlugs = fs
.readdirSync(`${chapterDirectory}/${projectSlug}`)
Expand Down Expand Up @@ -115,8 +137,14 @@ npm run test -- 1 --watch
});
}

const usesJest = projectUsesJest();

for (const stepSlug of stepSlugs) {
describe(stepSlug, () => {
if (usesJest) {
testContainsTestFile(stepSlug);
}

test("tsconfig.json", () => {
const tsconfigData = readFileAsJSON(
`${chapterDirectory}/${projectSlug}/${stepSlug}/tsconfig.json`,
Expand Down Expand Up @@ -145,6 +173,10 @@ npm run test -- 1 --watch

testPackageJson();

if (projectUsesJest()) {
testContainsTestFile("src");
}

test("README.md", () => {
const contents = fs
.readFileSync(`${chapterDirectory}/${projectSlug}/README.md`)
Expand Down
Loading