intermediate
Build the tool: find the tests that assert nothing
Implement this from the stub. Hidden tests grade the behaviour you write, not the comments you leave.
This exercise is real. This platform shipped 91 exercises, and two of them contained a test that asserted nothing — it called the function, ignored the result, and passed as long as the code compiled. Such a test cannot tell a correct implementation from a wrong one, so an exercise resting on it grades everybody as correct.
export interface Finding {
/** The file the test is in, as given. */
file: string
/** 1-based line of the test's opening line. */
line: number
/** The test's name, as written. */
name: string
}
export interface SourceFile {
path: string
contents: string
}
/**
* Reports every test that contains no assertion.
*
* A test counts as asserting if its body mentions `expect(`, `assert(` or
* `.should`. Tests are `it('name', ...)` or `test('name', ...)`; a `describe`
* block is not a test and does not need an assertion of its own.
*/
export function findAssertionlessTests(files: SourceFile[]): Finding[] {
// Your implementation here
return []
}challenge — implement from scratchCtrl+↵ submits · Ctrl+Shift+↵ runsstarter code