feat: allow for dynamic hints (#44279)
This commit is contained in:
committed by
GitHub
parent
63f6d9d3f2
commit
260f945de8
@ -98,9 +98,15 @@ async function initTestFrame(e = { code: {} }) {
|
|||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
// to provide useful debugging information when debugging the tests, we
|
// to provide useful debugging information when debugging the tests, we
|
||||||
// have to extract the message and stack before returning
|
// have to extract the message, stack and, if they exist, expected and
|
||||||
|
// actual before returning
|
||||||
return {
|
return {
|
||||||
err: { message: err.message, stack: err.stack }
|
err: {
|
||||||
|
message: err.message,
|
||||||
|
stack: err.stack,
|
||||||
|
expected: err.expected,
|
||||||
|
actual: err.actual
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -167,7 +167,11 @@ function* executeTests(testRunner, tests, testTimeout = 5000) {
|
|||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
newTest.message = text;
|
const { actual, expected } = err;
|
||||||
|
|
||||||
|
newTest.message = text
|
||||||
|
.replace('--fcc-expected--', expected)
|
||||||
|
.replace('--fcc-actual--', actual);
|
||||||
if (err === 'timeout') {
|
if (err === 'timeout') {
|
||||||
newTest.err = 'Test timed out';
|
newTest.err = 'Test timed out';
|
||||||
newTest.message = `${newTest.message} (${newTest.err})`;
|
newTest.message = `${newTest.message} (${newTest.err})`;
|
||||||
|
@ -64,10 +64,13 @@ Tests to run against user code, in pairs of markdown text and code block test co
|
|||||||
Code for test one
|
Code for test one
|
||||||
```
|
```
|
||||||
|
|
||||||
More instructions in markdown syntax
|
If you want dynamic output based on the user's code, --fcc-expected-- and --fcc-actual-- will be replaced with the expected and actual values of the test's assertion:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
More code
|
assert.equal(
|
||||||
|
'this will replace --fcc-actual--',
|
||||||
|
'this will replace --fcc-expected--'
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
# --seed--
|
# --seed--
|
||||||
|
Reference in New Issue
Block a user