In the Build a Bank API workshop (and others as well), the expected code is always part of the instructions. One could simply go ahead by copying and pasting the provided code blocks.
Where the code is placed is also often irrelevant because regex tests do no verify that the code works. Also, functionalities are partially tested.
For example, lesson 5 instructions:
Create a new file called db.js. This module will handle reading and writing accounts.json so the rest of your server doesn't have to worry about file I/O.
Import readFile and writeFile from Node's built-in fs/promises module, then export two async functions - getAccounts reads and parses accounts.json, and saveAccounts writes updated data back to it:
import { readFile, writeFile } from "fs/promises";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const DB_PATH = join(__dirname, "accounts.json");
export async function getAccounts() {
const data = await readFile(DB_PATH, "utf8");
return JSON.parse(data);
}
export async function saveAccounts(accounts) {
await writeFile(DB_PATH, JSON.stringify(accounts, null, 2));
}
You can either copy and paste this code and pass, or simply do this:
// import { readFile, writeFile } from "fs/promises";
// export function getAccounts() {}
// export function saveAccounts() {}
I know writing robust tests can be tricky but I believe we should improve this aspect in some way. Any thoughts?
In the Build a Bank API workshop (and others as well), the expected code is always part of the instructions. One could simply go ahead by copying and pasting the provided code blocks.
Where the code is placed is also often irrelevant because regex tests do no verify that the code works. Also, functionalities are partially tested.
For example, lesson 5 instructions:
You can either copy and paste this code and pass, or simply do this:
I know writing robust tests can be tricky but I believe we should improve this aspect in some way. Any thoughts?