Kirsty’s suite also checks a refusal. If you pass an unknown ability, such as "racer", the code must raise FittingError instead of choosing skis. Here’s her Python test:
Language: Python
import pytest
from fitting import FittingError, ski_length
def test_unknown_ability():
with pytest.raises(
FittingError, match="unknown ability: racer"
):
ski_length(170, "racer")
JavaScript’s assert.throws() does the same job, and a second argument of FittingError checks the class, as in pytest. The first argument is where the port differs.
Hand assert.throws() a Function
The natural port moves the with block’s line into the first argument. Replace fitting.test.js with this test, and predict what node --test reports: