currently doing the js track but i encounted this error on
https://exercism.org/tracks/javascript/exercises/coordinate-transformation
We received the following error when we ran your code:
● Test suite failed to run
currently doing the js track but i encounted this error on
https://exercism.org/tracks/javascript/exercises/coordinate-transformation
● Test suite failed to run
Please show us your code, so that we can reproduce.
Please use a code block:
```javascript
export function hello() {
return 'Goodbye, Mars!';
}
```
export function hello() {
return 'Goodbye, Mars!';
}
no changes to the excercise start code…
The error contains another line, which tells you how to fix it.
The complete error is
We received the following error when we ran your code:
● Test suite failed to run Implement the translate2d function
AN ERROR OCCURRED
● Test suite failed to run
Implement the translate2d function
export function translate2d(dx, dy) {
throw new Error(‘Implement the translate2d function’);
}
this code is working on my local machine hmmm…
function translate2d(dx, dy) {
return (x, y) => [x + dx, dy + y];
}
console.log(translate2d(2, 0));
const moveCoordinatesRight2Px = translate2d(2, 0);
const result = moveCoordinatesRight2Px(4, 8);
console.log(result);
Having looked at the tests’ code, I now suspect the test suite crashes because the tests on composeTransform
depend on translate2d
and scale2d
, and their stub implementations have them crash.
@Aster255 What do you feel is actually the problem here? Do you find the error message unclear, or do you not like that the test suite crashes at all, or…?
was used to editing the functions, one at a time from the previous excercises. only when you pointed out the second line of the error message and removing the throws did i manage to progress…
Right, it would make more sense for applicable tests to just run and for inapplicable to not run, or fail.
@SleeplessByte Could dependencies between tests be specified somehow? Or should these tests be amended in some other way?
Sorry I don’t understand the issue nor the request.
When either of translate2d
and scale2d
is not implemented (or rather: throws), the tests crash. The issue is that there is a crash, as opposed to test failure.
In contrast, when composeTransform
is not implemented yet but translate2d
and scale2d
are, the tests do not crash but instead fail properly.
The wish would be for all missing implementations to have the same effect, namely proper test failures, without crashes, so that this exercise can be solved incrementally.
Taken from a different exercise, the wish is the expected behaviour:
The reason this does not work is because of the following lines:
They need to be moved inside the test, above the expectation. For example the first one should be:
const dx = 3;
const dy = -5;
- const translator = translate2d(dx, dy);
const x1 = 0;
const y1 = 0;
const expected = [3, -5];
test('should be predictable', () => {
+ const translator = translate2d(dx, dy);
expect(translator(x1, y1)).toEqual(expected);
});
However, this change also requires the next test to change (etc):
const x2 = 4;
const y2 = 5;
const reusedExpected = [7, 0];
test('should be reusable', () => {
+ const translator = translate2d(dx, dy);
+ translator(x1, y1);
+
expect(translator(x2, y2)).toEqual(reusedExpected);
});
We’ll take a PR.