Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useStrict does not throw error #998

Closed
fehergeri13 opened this issue May 16, 2017 · 2 comments
Closed

useStrict does not throw error #998

fehergeri13 opened this issue May 16, 2017 · 2 comments

Comments

@fehergeri13
Copy link

fehergeri13 commented May 16, 2017

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
});
@fehergeri13
Copy link
Author

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
});

@urugator
Copy link
Collaborator

In short strict mode doesn't throw unless the observable is observed by something (autorun/reaction).
For more info see this and #798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants