Skip to content

Commit

Permalink
add test for exercise 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Sep 24, 2024
1 parent 3f79ded commit 876136f
Show file tree
Hide file tree
Showing 67 changed files with 1,590 additions and 95 deletions.
1 change: 1 addition & 0 deletions epicshop/.diffignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tsconfig.json
countries-110m.json
us-cities.json
tests/
21 changes: 21 additions & 0 deletions epicshop/fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function relativeToWorkshopRoot(dir) {
}

await updatePkgNames()
await copyTestFiles()
await updateTsconfig()

async function updatePkgNames() {
Expand All @@ -63,6 +64,26 @@ async function updatePkgNames() {
}
}

async function copyTestFiles() {
for (const app of exerciseApps) {
if (app.includes('problem')) {
const solutionApp = app.replace('problem', 'solution')
const testDir = path.join(solutionApp, 'tests')
const destTestDir = path.join(app, 'tests')

if (exists(testDir)) {
// Remove existing test directory in problem app if it exists
if (exists(destTestDir)) {
await fs.promises.rm(destTestDir, { recursive: true, force: true })
}

// Copy the entire test directory from solution to problem
await fs.promises.cp(testDir, destTestDir, { recursive: true })
}
}
}
}

async function updateTsconfig() {
const tsconfig = {
files: [],
Expand Down
140 changes: 131 additions & 9 deletions epicshop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions epicshop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"type": "module",
"scripts": {
"test:setup": "playwright install chromium --with-deps",
"test": "playwright test"
"test": "playwright test && node test.js"
},
"dependencies": {
"@epic-web/config": "^1.11.2",
"@epic-web/workshop-app": "^4.28.2",
"@epic-web/workshop-utils": "^4.28.2",
"execa": "^9.2.0"
"enquirer": "^2.4.1",
"execa": "^9.4.0",
"match-sorter": "^6.3.4",
"p-limit": "^6.1.0"
}
}
Loading

0 comments on commit 876136f

Please sign in to comment.