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

Make dev.warn tests resilient to new warnings #302

Closed
phillipskevin opened this issue Sep 8, 2017 · 3 comments · Fixed by #307
Closed

Make dev.warn tests resilient to new warnings #302

phillipskevin opened this issue Sep 8, 2017 · 3 comments · Fixed by #307
Assignees

Comments

@phillipskevin
Copy link
Contributor

We have many tests that assert the value of a warning message. When other can-* repos add new warnings, these tests often break. We should use a flag to only assert the value of warning messages when we're making the stache(...) call we're trying to test. We should be able to do this with a simple flag:

var checkWarnings = false;
canDev.warn = function(text) {
    if (checkWarnings){ 
        equal(text, texts[count++]);
    }
};

...

checkWarnings = true;
stache(...);

...
@phillipskevin
Copy link
Contributor Author

Another option (given by @christopherjbaker via @imaustink) is to only assert if the warning matches the expected value along with expect(...) to make sure the correct number of warnings are given like this test.

@christopherjbaker
Copy link

I think the best option would be a built in mechanism, something like canDev.mockWarn('expected warning') or canDev.mockWarn([ 'expected warning', 'other warning' ]). Besides simplifying the tests instead of having that code every time, it would also make future changes to this logic simpler. =]

@phillipskevin
Copy link
Contributor Author

We may want to create a can-test-helpers module for useful functions like this.

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

Successfully merging a pull request may close this issue.

3 participants