Results 1 to 2 of 2

Thread: Is there a way to deliberately make a test fail?

  1. #1

    Default Answered: Is there a way to deliberately make a test fail?

    Say I am writing a bit of non-ST code inside a seperate function and may want to make my test fail or continue based on this functions result.

    How would I do this?

    I've seen some stuff in the API documentation but am not sure if I am using it correctly
    Code:
    describe("asdf", function(done) {
        it("should pass", function() {
            reject().then(function(){
                alert("wont happen");
            }).catch(function(e){
                ST.WatchDog.fail(e);
            });
        });
    });
    
    
    function reject (){
        return Promise.reject("custom message")
    }
    This is from the jasmine docs and does not work either
    Code:
    describe("asdf", function(done) {
        it("should pass", function() {
            reject().then(function(){
                alert("wont happen");
            }).catch(function(e){
                         done.fail(e);
            });
        });
    });
    
    
    function reject (){
        return Promise.reject("custom message")
    }
    I am getting the following error everytime:
    Error: describe does not expect any arguments at Env.describe (C:\Program Files\Sencha\Test\2_2_1_83\resources\app.asar\node_modules\orion-core\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:828:15) at doDescribe (C:\Program Files\Sencha\Test\2_2_1_83\resources\app.asar\node_modules\orion-core\serve\jasmine-post-extensions.js:52:26) at Object.fn (C:\Program Files\Sencha\Test\2_2_1_83\resources\app.asar\node_modules\orion-core\serve\jasmine-post-extensions.js:90:20) at next (C:\Program Files\Sencha\Test\2_2_1_83\resources\app.asar\node_modules\orion-core\serve\orion.js:918:24)

  2. You can use the "fail" method in Jasmine to mark a test as failed, and provide a custom error message:

    Code:
    it('should fail', function() {
        fail('Here is my custom error'); 
    });
    Also, I noticed the code samples you provided above show the "done" parameter being used within the "describe" function - it should instead be placed within the "it" function.

  3. #2
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    London, England
    Posts
    354
    Answers
    61

    Default

    You can use the "fail" method in Jasmine to mark a test as failed, and provide a custom error message:

    Code:
    it('should fail', function() {
        fail('Here is my custom error'); 
    });
    Also, I noticed the code samples you provided above show the "done" parameter being used within the "describe" function - it should instead be placed within the "it" function.
    Daniel Gallo
    Sales Engineer
    Sencha

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •