Using jest:
foo.test.js
import {useStrict, observable} from 'mobx';
it('should throw an exception', () => {
expect(()=>{
let foo = observable.map();
useStrict(true);
foo.set('foo','foo');
}).toThrow(); //no exception is thrown
});
it('should throw an exception 2', () => {
useStrict(true);
class Foo {
@observable foo = '';
}
expect(()=>{
let foo = new Foo();
foo.foo = 'bar';
}).toThrow(); //no exception is thrown
});
In short strict mode doesn't throw unless the observable is observed by something (autorun/reaction).
For more info see this and #798
Most helpful comment
In short strict mode doesn't throw unless the observable is observed by something (autorun/reaction).
For more info see this and #798