Results 1 to 3 of 3

Thread: Can you output an array to the test summary

  1. #1
    Sencha User
    Join Date
    Mar 2020
    Posts
    12
    Answers
    1

    Default Answered: Can you output an array to the test summary

    Is it possible to output the value of an array to the test summary so that it can be manually checked if necessary?

    For example, I have an array called 'matchedRows' and it contains the values [ 0, 2, 3, 8, 9, 10, 11, 16, 17, 19, 20, 24 ] which are the row numbers found in a previous test. I was hoping to write something like:

    Code:
    expect(matchedRows).toBeNan;
    or

    Code:
    Expect(matchedRows).toThrowError;
    and the contents of the array to be shown in the Sencha Test summary with a passed test. However, as the tests pass they are not outputted to the summary.

    I can write something like the following and the tests will pass and each element of the array will be disaplayed in the Sencha Test Summary but I wanted to output the whole array in one line.

    Code:
    if(noMatch.length > 0)
    {
       for (i = 0; i < matchedRows.length; i ++) {
          expect(matchedRows[i]).toBeLessThan(999);            
       }
    }
    Basically, I would like to know how to force the output of a test to the summary even if it passes so that I can show the contents of an array.

    Many thanks.

  2. Jasmine lets you tag on an additional message as part of the "to" function. This will allow you to output additional wording or values, for example:


    Code:
    var numbers = [2, 5, 9, 10];
    
    ST.textField('numberfield[fieldLabel="Age"]')
        .expect('value')
        .toEqual(20, 'Numbers:', numbers);
    or

    Code:
    expect(20).toEqual(20, 'Numbers:', numbers);

    If the test passes or fails, the additional wording will always be appended to the pass/fail text.

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

    Default

    Jasmine lets you tag on an additional message as part of the "to" function. This will allow you to output additional wording or values, for example:


    Code:
    var numbers = [2, 5, 9, 10];
    
    ST.textField('numberfield[fieldLabel="Age"]')
        .expect('value')
        .toEqual(20, 'Numbers:', numbers);
    or

    Code:
    expect(20).toEqual(20, 'Numbers:', numbers);

    If the test passes or fails, the additional wording will always be appended to the pass/fail text.
    Daniel Gallo
    Sales Engineer
    Sencha

  4. #3
    Sencha User
    Join Date
    Mar 2020
    Posts
    12
    Answers
    1

    Default

    Thanks Daniel. That is exactly what I needed and is very useful for some of the other tests I have written.

    Good to know.

    Thanks.

Posting Permissions

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