alsatian
alsatian copied to clipboard
TestCase mutable properties display issue
As of 2.3.0, a test whose TestCase contains an object that gets modified during the test run will display the final value of the object, if the test fails. This hinders identification of the failed test case.
import { Test, TestCase, Expect, FocusTests } from "alsatian";
@FocusTests
export class Thingy {
@TestCase({a: false})
@Test()
atest(dict: any) {
new SomethingToTest().amethod(dict);
Expect(dict).toBeNull();
}
}
export class SomethingToTest {
amethod(dict: any) {
dict["a"] = true;
}
}
Results in the output:
# FIXTURE Thingy
not ok 24 atest ( {"a":true} )
...
But, a
should be false
. An obvious fix/workaround is just to clone the object before sending it into the test/tested method.
Good spot @cdibbs probably a bit longer standing than 2.3.0 but a bug nonetheless, I'm currently working on a revamp for 3.0.0 and will try and sneak this in too since should be quite easy :) if it's urgent for you though I am of course as always open to PRs 👍
Sweet! Can't wait to try it out. This particular issue has been a minor, cosmetic nuisance, so far, but if it bugs me too much, I'll send a PR your way. :-) Thanks!