Cypress本身有比较完备的报告体系,其继承于Macha的测试报告,任何Mocha支持的测试报告均可直接用于Cypress

前提

内置的测试报告

内置的测试报告包括Mocha的内置测试报告和直接嵌入在Cypress中的测试报告,主要包括如下几种

spec报告

它是Mocha内置的报告,输出的是一组嵌套的分级视图,使用起来极其简单,只需要在cypress run命令后加上--reporter=spec参数即可,执行结果如下所示

使用yarn执行测试

D:\Cypress>yarn cypress:run --reporter=spec
yarn run v1.22.10
$ cypress run --reporter=spec


====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      4 found (examples\actions.spec.js, examples\aliasing.spec.js, examples\assertions. │
  │             spec.js, examples\connectors.spec.js)                                              │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 4)


  Actions
    √ .type() - type into a DOM element (8195ms)
    √ .focus() - focus on a DOM element (1114ms)
    √ .blur() - blur off a DOM element (913ms)
    √ .clear() - clears an input or textarea element (1356ms)
    √ .submit() - submit a form (1037ms)
    √ .click() - click on a DOM element (3083ms)
    √ .dblclick() - double click on a DOM element (730ms)
    √ .rightclick() - right click on a DOM element (653ms)
    √ .check() - check a checkbox or radio element (1597ms)
    √ .uncheck() - uncheck a checkbox element (1611ms)
    √ .select() - select an option in a <select> element (1538ms)
    √ .scrollIntoView() - scroll an element into view (664ms)
    √ .trigger() - trigger an event on a DOM element (464ms)
    √ cy.scrollTo() - scroll the window or element to a position (2438ms)


  14 passing (30s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     29 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (8 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\aliasing.spec.js                                                       (2 of 4)


  Aliasing
    √ .as() - alias a DOM element for later use (2286ms)
    √ .as() - alias a route for later use (2194ms)


  2 passing (6s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        2                                                                                │
  │ Passing:      2                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     6 seconds                                                                        │
  │ Spec Ran:     examples\aliasing.spec.js                                                        │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\aliasing.spec.js.mp4        (2 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\assertions.spec.js                                                     (3 of 4)


  Assertions
    Implicit Assertions
      √ .should() - make an assertion about the current subject (2265ms)
      √ .and() - chain multiple assertions together (413ms)
    Explicit Assertions
      √ expect - make an assertion about a specified subject (376ms)
      √ pass your own callback function to should() (330ms)
      √ finds element by class name regex (327ms)
      √ can throw any error (466ms)
      √ matches unknown text between two elements (455ms)
      √ assert - assert shape of an object (468ms)
      √ retries the should callback until assertions pass (1812ms)


  9 passing (9s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        9                                                                                │
  │ Passing:      9                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     9 seconds                                                                        │
  │ Spec Ran:     examples\assertions.spec.js                                                      │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\assertions.spec.js.mp4      (3 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\connectors.spec.js                                                     (4 of 4)


  Connectors
    √ .each() - iterate over an array of elements (1622ms)
    √ .its() - get properties on the current subject (486ms)
    √ .invoke() - invoke a function on the current subject (329ms)
    √ .spread() - spread an array as individual args to callback function (311ms)
    .then()
      √ invokes a callback function with the current subject (482ms)
      √ yields the returned value to the next command (285ms)
      √ yields the original subject without return (386ms)
      √ yields the value yielded by the last Cypress command inside (295ms)


  8 passing (6s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        8                                                                                │
  │ Passing:      8                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     5 seconds                                                                        │
  │ Spec Ran:     examples\connectors.spec.js                                                      │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\connectors.spec.js.mp4      (2 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:29       14       14        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\aliasing.spec.js                00:06        2        2        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\assertions.spec.js              00:09        9        9        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\connectors.spec.js              00:05        8        8        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:51       33       33        -        -        -

Done in 95.33s.

使用cypress直接执行

	C:\Users\Administrator\node_modules\.bin>cypress run --reporter=spec
	
	====================================================================================================
	  (Run Starting)
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Cypress:    6.1.0                                                                              │
	  │ Browser:    Electron 87 (headless)                                                             │
	  │ Specs:      20 found (examples\actions.spec.js, examples\aliasing.spec.js, examples\assertions │
	  │             .spec.js, examples\connectors.spec.js, examples\cookies.spec.js, examples\cypress_ │
	  │             api.spec.js, examples\files.spec.js, examples\local_storage.spec.js, examples\loca │
	  │             tion.spec.j...)                                                                    │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	────────────────────────────────────────────────────────────────────────────────────────────────────
	  Running:  examples\actions.spec.js                                                       (1 of 20)
	  Actions
	    √ .type() - type into a DOM element (6654ms)
	    √ .focus() - focus on a DOM element (800ms)
	    √ .blur() - blur off a DOM element (644ms)
	    √ .clear() - clears an input or textarea element (747ms)
	    √ .submit() - submit a form (633ms)
	    √ .click() - click on a DOM element (2300ms)
	    √ .dblclick() - double click on a DOM element (426ms)
	    √ .rightclick() - right click on a DOM element (564ms)
	    √ .check() - check a checkbox or radio element (1162ms)
	    √ .uncheck() - uncheck a checkbox element (1275ms)
	    √ .select() - select an option in a <select> element (1128ms)
	    √ .scrollIntoView() - scroll an element into view (391ms)
	    √ .trigger() - trigger an event on a DOM element (634ms)
	    √ cy.scrollTo() - scroll the window or element to a position (2313ms)
	  14 passing (23s)
	  (Results)
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Tests:        14                                                                               │
	  │ Passing:      14                                                                               │
	  │ Failing:      0                                                                                │
	  │ Pending:      0                                                                                │
	  │ Skipped:      0                                                                                │
	  │ Screenshots:  0                                                                                │
	  │ Video:        true                                                                             │
	  │ Duration:     22 seconds                                                                       │
	  │ Spec Ran:     examples\actions.spec.js                                                         │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	  (Video)
	
	  -  Started processing:  Compressing to 32 CRF
	  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa    (4 seconds)
	                          mples\actions.spec.js.mp4
	────────────────────────────────────────────────────────────────────────────────────────────────────
	  Running:  examples\aliasing.spec.js                                                      (2 of 20)
	  Aliasing
	    √ .as() - alias a DOM element for later use (1576ms)
	    √ .as() - alias a route for later use (2135ms)
	  2 passing (5s)
	  (Results)
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Tests:        2                                                                                │
	  │ Passing:      2                                                                                │
	  │ Failing:      0                                                                                │
	  │ Pending:      0                                                                                │
	  │ Skipped:      0                                                                                │
	  │ Screenshots:  0                                                                                │
	  │ Video:        true                                                                             │
	  │ Duration:     5 seconds                                                                        │
	  │ Spec Ran:     examples\aliasing.spec.js                                                        │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	  (Video)
	
	  -  Started processing:  Compressing to 32 CRF
	  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa     (1 second)
	                          mples\aliasing.spec.js.mp4
	────────────────────────────────────────────────────────────────────────────────────────────────────
	  Running:  examples\assertions.spec.js                                                    (3 of 20)
	  Assertions
	    Implicit Assertions
	      √ .should() - make an assertion about the current subject (1917ms)
	      √ .and() - chain multiple assertions together (486ms)
	    Explicit Assertions
	      √ expect - make an assertion about a specified subject (487ms)
	      √ pass your own callback function to should() (386ms)
	      √ finds element by class name regex (305ms)
	      √ can throw any error (303ms)
	      √ matches unknown text between two elements (443ms)
	      √ assert - assert shape of an object (271ms)
	      √ retries the should callback until assertions pass (1757ms)
	  9 passing (9s)
	  (Results)
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Tests:        9                                                                                │
	  │ Passing:      9                                                                                │
	  │ Failing:      0                                                                                │
	  │ Pending:      0                                                                                │
	  │ Skipped:      0                                                                                │
	  │ Screenshots:  0                                                                                │
	  │ Video:        true                                                                             │
	  │ Duration:     8 seconds                                                                        │
	  │ Spec Ran:     examples\assertions.spec.js                                                      │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	  (Video)
	
	  -  Started processing:  Compressing to 32 CRF
	  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa     (1 second)
	                          mples\assertions.spec.js.mp4
	                          
	────────────────────────────────────────────────────────────────────────────────────────────────────
	..............................................**省略部分用例**.......................................
	────────────────────────────────────────────────────────────────────────────────────────────────────
	
	────────────────────────────────────────────────────────────────────────────────────────────────────
	  Running:  testConfig.js                                                                 (20 of 20)
	  登陆
	    HTML表单登陆测试
	      1) 登陆成功, 跳转到dashboard页
	  0 passing (7s)
	  1 failing
	  1) 登陆
	       HTML表单登陆测试
	         登陆成功, 跳转到dashboard页:
	     AssertionError: Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'
	      at Context.eval (http://localhost:7077/__cypress/tests?p=cypress\integration\testConfig.js:113:13)
	  (Results)
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Tests:        1                                                                                │
	  │ Passing:      0                                                                                │
	  │ Failing:      1                                                                                │
	  │ Pending:      0                                                                                │
	  │ Skipped:      0                                                                                │
	  │ Screenshots:  1                                                                                │
	  │ Video:        true                                                                             │
	  │ Duration:     7 seconds                                                                        │
	  │ Spec Ran:     testConfig.js                                                                    │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	  (Screenshots)
	  -  C:\Users\Administrator\node_modules\.bin\cypress\screenshots\testConfig.js\登陆…     (1280x720)
	      HTML表单登陆测试 -- 登陆成功, 跳转到dashboard页 (failed).png
	  (Video)
	  -  Started processing:  Compressing to 32 CRF
	  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\tes     (1 second)
	                          tConfig.js.mp4
	====================================================================================================
	  (Run Finished)
	       Spec                                              Tests  Passing  Failing  Pending  Skipped
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ √  examples\actions.spec.js                 00:22       14       14        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\aliasing.spec.js                00:05        2        2        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\assertions.spec.js              00:08        9        9        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\connectors.spec.js              00:06        8        8        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\cookies.spec.js                 00:07        5        5        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\cypress_api.spec.js             00:08       12       12        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\files.spec.js                   00:06        4        4        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\local_storage.spec.js           00:04        1        1        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\location.spec.js                00:04        3        3        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\misc.spec.js                    00:08        6        6        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\navigation.spec.js              00:08        3        3        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\network_requests.spec.js        00:16        6        6        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\querying.spec.js                00:07        5        5        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\spies_stubs_clocks.spec.js      00:08        7        7        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\traversal.spec.js               00:14       18       18        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\utilities.spec.js               00:08        6        6        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\viewport.spec.js                00:07        1        1        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\waiting.spec.js                 00:12        2        2        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\window.spec.js                  00:04        3        3        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ ×  testConfig.js                            00:07        1        -        1        -        - │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	    ×  1 of 20 failed (5%)                      03:00      116      115        1        -        -

使用npm执行测试

D:\Cypress>npm run cypress:run --reporter=spec

> davieyang@1.0.0 cypress:run D:\Cypress
> cypress run



====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      4 found (examples\actions.spec.js, examples\aliasing.spec.js, examples\assertions. │
  │             spec.js, examples\connectors.spec.js)                                              │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 4)


  Actions
    √ .type() - type into a DOM element (8509ms)
    √ .focus() - focus on a DOM element (892ms)
    √ .blur() - blur off a DOM element (986ms)
    √ .clear() - clears an input or textarea element (1112ms)
    √ .submit() - submit a form (962ms)
    √ .click() - click on a DOM element (2762ms)
    √ .dblclick() - double click on a DOM element (834ms)
    √ .rightclick() - right click on a DOM element (522ms)
    √ .check() - check a checkbox or radio element (1516ms)
    √ .uncheck() - uncheck a checkbox element (1464ms)
    √ .select() - select an option in a <select> element (1632ms)
    √ .scrollIntoView() - scroll an element into view (626ms)
    √ .trigger() - trigger an event on a DOM element (705ms)
    √ cy.scrollTo() - scroll the window or element to a position (2363ms)


  14 passing (28s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     27 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (8 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\aliasing.spec.js                                                       (2 of 4)


  Aliasing
    √ .as() - alias a DOM element for later use (1994ms)
    √ .as() - alias a route for later use (1723ms)


  2 passing (5s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        2                                                                                │
  │ Passing:      2                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     5 seconds                                                                        │
  │ Spec Ran:     examples\aliasing.spec.js                                                        │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\aliasing.spec.js.mp4         (1 second)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\assertions.spec.js                                                     (3 of 4)


  Assertions
    Implicit Assertions
      √ .should() - make an assertion about the current subject (2396ms)
      √ .and() - chain multiple assertions together (545ms)
    Explicit Assertions
      √ expect - make an assertion about a specified subject (454ms)
      √ pass your own callback function to should() (308ms)
      √ finds element by class name regex (524ms)
      √ can throw any error (505ms)
      √ matches unknown text between two elements (333ms)
      √ assert - assert shape of an object (513ms)
      √ retries the should callback until assertions pass (1851ms)


  9 passing (10s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        9                                                                                │
  │ Passing:      9                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     9 seconds                                                                        │
  │ Spec Ran:     examples\assertions.spec.js                                                      │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\assertions.spec.js.mp4      (3 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\connectors.spec.js                                                     (4 of 4)


  Connectors
    √ .each() - iterate over an array of elements (1953ms)
    √ .its() - get properties on the current subject (304ms)
    √ .invoke() - invoke a function on the current subject (311ms)
    √ .spread() - spread an array as individual args to callback function (313ms)
    .then()
      √ invokes a callback function with the current subject (434ms)
      √ yields the returned value to the next command (288ms)
      √ yields the original subject without return (303ms)
      √ yields the value yielded by the last Cypress command inside (297ms)


  8 passing (7s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        8                                                                                │
  │ Passing:      8                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     6 seconds                                                                        │
  │ Spec Ran:     examples\connectors.spec.js                                                      │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\connectors.spec.js.mp4      (2 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:27       14       14        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\aliasing.spec.js                00:05        2        2        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\assertions.spec.js              00:09        9        9        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\connectors.spec.js              00:06        8        8        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:49       33       33        -        -        -

json报告

它输出一个大的JSON对象,cypress使用json格式的测试报告,只需要在命令行cypress run命令后加上reporter=json参数即可,执行结果如下所示

使用yarn执行测试


D:\Cypress>yarn cypress:run --reporter=json --reporter-options "toConsole=true"
yarn run v1.22.10
$ cypress run --reporter=json --reporter-options toConsole=true



====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      4 found (examples\actions.spec.js, examples\aliasing.spec.js, examples\assertions. │
  │             spec.js, examples\connectors.spec.js)                                              │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 4)
{
  "stats": {
    "suites": 1,
    "tests": 14,
    "passes": 14,
    "pending": 0,
    "failures": 0,
    "start": "2020-12-27T12:21:12.144Z",
    "end": "2020-12-27T12:21:38.554Z",
    "duration": 26410
  },
  "tests": [
    {
      "title": ".type() - type into a DOM element",
      "fullTitle": "Actions .type() - type into a DOM element",
      "duration": 7869,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".focus() - focus on a DOM element",
      "fullTitle": "Actions .focus() - focus on a DOM element",
      "duration": 940,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".blur() - blur off a DOM element",
      "fullTitle": "Actions .blur() - blur off a DOM element",
      "duration": 936,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".clear() - clears an input or textarea element",
      "fullTitle": "Actions .clear() - clears an input or textarea element",
      "duration": 905,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".submit() - submit a form",
      "fullTitle": "Actions .submit() - submit a form",
      "duration": 713,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".click() - click on a DOM element",
      "fullTitle": "Actions .click() - click on a DOM element",
      "duration": 2619,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".dblclick() - double click on a DOM element",
      "fullTitle": "Actions .dblclick() - double click on a DOM element",
      "duration": 600,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".rightclick() - right click on a DOM element",
      "fullTitle": "Actions .rightclick() - right click on a DOM element",
      "duration": 563,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".check() - check a checkbox or radio element",
      "fullTitle": "Actions .check() - check a checkbox or radio element",
      "duration": 1385,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".uncheck() - uncheck a checkbox element",
      "fullTitle": "Actions .uncheck() - uncheck a checkbox element",
      "duration": 1607,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".select() - select an option in a <select> element",
      "fullTitle": "Actions .select() - select an option in a <select> element",
      "duration": 1498,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".scrollIntoView() - scroll an element into view",
      "fullTitle": "Actions .scrollIntoView() - scroll an element into view",
      "duration": 598,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".trigger() - trigger an event on a DOM element",
      "fullTitle": "Actions .trigger() - trigger an event on a DOM element",
      "duration": 476,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "cy.scrollTo() - scroll the window or element to a position",
      "fullTitle": "Actions cy.scrollTo() - scroll the window or element to a position",
      "duration": 2377,
      "currentRetry": 0,
      "err": {}
    }
  ],
  "pending": [],
  "failures": [],
  "passes": [
    {
      "title": ".type() - type into a DOM element",
      "fullTitle": "Actions .type() - type into a DOM element",
      "duration": 7869,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".focus() - focus on a DOM element",
      "fullTitle": "Actions .focus() - focus on a DOM element",
      "duration": 940,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".blur() - blur off a DOM element",
      "fullTitle": "Actions .blur() - blur off a DOM element",
      "duration": 936,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".clear() - clears an input or textarea element",
      "fullTitle": "Actions .clear() - clears an input or textarea element",
      "duration": 905,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".submit() - submit a form",
      "fullTitle": "Actions .submit() - submit a form",
      "duration": 713,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".click() - click on a DOM element",
      "fullTitle": "Actions .click() - click on a DOM element",
      "duration": 2619,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".dblclick() - double click on a DOM element",
      "fullTitle": "Actions .dblclick() - double click on a DOM element",
      "duration": 600,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".rightclick() - right click on a DOM element",
      "fullTitle": "Actions .rightclick() - right click on a DOM element",
      "duration": 563,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".check() - check a checkbox or radio element",
      "fullTitle": "Actions .check() - check a checkbox or radio element",
      "duration": 1385,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".uncheck() - uncheck a checkbox element",
      "fullTitle": "Actions .uncheck() - uncheck a checkbox element",
      "duration": 1607,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".select() - select an option in a <select> element",
      "fullTitle": "Actions .select() - select an option in a <select> element",
      "duration": 1498,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".scrollIntoView() - scroll an element into view",
      "fullTitle": "Actions .scrollIntoView() - scroll an element into view",
      "duration": 598,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".trigger() - trigger an event on a DOM element",
      "fullTitle": "Actions .trigger() - trigger an event on a DOM element",
      "duration": 476,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "cy.scrollTo() - scroll the window or element to a position",
      "fullTitle": "Actions cy.scrollTo() - scroll the window or element to a position",
      "duration": 2377,
      "currentRetry": 0,
      "err": {}
    }
  ]
}
  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     26 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (8 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\aliasing.spec.js                                                       (2 of 4)
{
  "stats": {
    "suites": 1,
    "tests": 2,
    "passes": 2,
    "pending": 0,
    "failures": 0,
    "start": "2020-12-27T12:21:49.563Z",
    "end": "2020-12-27T12:21:54.690Z",
    "duration": 5127
  },
  "tests": [
    {
      "title": ".as() - alias a DOM element for later use",
      "fullTitle": "Aliasing .as() - alias a DOM element for later use",
      "duration": 1571,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".as() - alias a route for later use",
      "fullTitle": "Aliasing .as() - alias a route for later use",
      "duration": 2022,
      "currentRetry": 0,
      "err": {}
    }
  ],
  "pending": [],
  "failures": [],
  "passes": [
    {
      "title": ".as() - alias a DOM element for later use",
      "fullTitle": "Aliasing .as() - alias a DOM element for later use",
      "duration": 1571,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".as() - alias a route for later use",
      "fullTitle": "Aliasing .as() - alias a route for later use",
      "duration": 2022,
      "currentRetry": 0,
      "err": {}
    }
  ]
}
  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        2                                                                                │
  │ Passing:      2                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     5 seconds                                                                        │
  │ Spec Ran:     examples\aliasing.spec.js                                                        │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\aliasing.spec.js.mp4        (2 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\assertions.spec.js                                                     (3 of 4)
{
  "stats": {
    "suites": 3,
    "tests": 9,
    "passes": 9,
    "pending": 0,
    "failures": 0,
    "start": "2020-12-27T12:22:00.844Z",
    "end": "2020-12-27T12:22:10.711Z",
    "duration": 9867
  },
  "tests": [
    {
      "title": ".should() - make an assertion about the current subject",
      "fullTitle": "Assertions Implicit Assertions .should() - make an assertion about the current subject",
      "duration": 2456,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".and() - chain multiple assertions together",
      "fullTitle": "Assertions Implicit Assertions .and() - chain multiple assertions together",
      "duration": 469,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "expect - make an assertion about a specified subject",
      "fullTitle": "Assertions Explicit Assertions expect - make an assertion about a specified subject",
      "duration": 466,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "pass your own callback function to should()",
      "fullTitle": "Assertions Explicit Assertions pass your own callback function to should()",
      "duration": 565,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "finds element by class name regex",
      "fullTitle": "Assertions Explicit Assertions finds element by class name regex",
      "duration": 359,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "can throw any error",
      "fullTitle": "Assertions Explicit Assertions can throw any error",
      "duration": 514,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "matches unknown text between two elements",
      "fullTitle": "Assertions Explicit Assertions matches unknown text between two elements",
      "duration": 361,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "assert - assert shape of an object",
      "fullTitle": "Assertions Explicit Assertions assert - assert shape of an object",
      "duration": 497,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "retries the should callback until assertions pass",
      "fullTitle": "Assertions Explicit Assertions retries the should callback until assertions pass",
      "duration": 1960,
      "currentRetry": 0,
      "err": {}
    }
  ],
  "pending": [],
  "failures": [],
  "passes": [
    {
      "title": ".should() - make an assertion about the current subject",
      "fullTitle": "Assertions Implicit Assertions .should() - make an assertion about the current subject",
      "duration": 2456,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".and() - chain multiple assertions together",
      "fullTitle": "Assertions Implicit Assertions .and() - chain multiple assertions together",
      "duration": 469,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "expect - make an assertion about a specified subject",
      "fullTitle": "Assertions Explicit Assertions expect - make an assertion about a specified subject",
      "duration": 466,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "pass your own callback function to should()",
      "fullTitle": "Assertions Explicit Assertions pass your own callback function to should()",
      "duration": 565,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "finds element by class name regex",
      "fullTitle": "Assertions Explicit Assertions finds element by class name regex",
      "duration": 359,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "can throw any error",
      "fullTitle": "Assertions Explicit Assertions can throw any error",
      "duration": 514,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "matches unknown text between two elements",
      "fullTitle": "Assertions Explicit Assertions matches unknown text between two elements",
      "duration": 361,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "assert - assert shape of an object",
      "fullTitle": "Assertions Explicit Assertions assert - assert shape of an object",
      "duration": 497,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "retries the should callback until assertions pass",
      "fullTitle": "Assertions Explicit Assertions retries the should callback until assertions pass",
      "duration": 1960,
      "currentRetry": 0,
      "err": {}
    }
  ]
}
  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        9                                                                                │
  │ Passing:      9                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     9 seconds                                                                        │
  │ Spec Ran:     examples\assertions.spec.js                                                      │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\assertions.spec.js.mp4      (4 seconds)


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\connectors.spec.js                                                     (4 of 4)
{
  "stats": {
    "suites": 2,
    "tests": 8,
    "passes": 8,
    "pending": 0,
    "failures": 0,
    "start": "2020-12-27T12:22:17.957Z",
    "end": "2020-12-27T12:22:24.065Z",
    "duration": 6108
  },
  "tests": [
    {
      "title": ".each() - iterate over an array of elements",
      "fullTitle": "Connectors .each() - iterate over an array of elements",
      "duration": 2075,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".its() - get properties on the current subject",
      "fullTitle": "Connectors .its() - get properties on the current subject",
      "duration": 354,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".invoke() - invoke a function on the current subject",
      "fullTitle": "Connectors .invoke() - invoke a function on the current subject",
      "duration": 284,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".spread() - spread an array as individual args to callback function",
      "fullTitle": "Connectors .spread() - spread an array as individual args to callback function",
      "duration": 290,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "invokes a callback function with the current subject",
      "fullTitle": "Connectors .then() invokes a callback function with the current subject",
      "duration": 482,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "yields the returned value to the next command",
      "fullTitle": "Connectors .then() yields the returned value to the next command",
      "duration": 301,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "yields the original subject without return",
      "fullTitle": "Connectors .then() yields the original subject without return",
      "duration": 363,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "yields the value yielded by the last Cypress command inside",
      "fullTitle": "Connectors .then() yields the value yielded by the last Cypress command inside",
      "duration": 269,
      "currentRetry": 0,
      "err": {}
    }
  ],
  "pending": [],
  "failures": [],
  "passes": [
    {
      "title": ".each() - iterate over an array of elements",
      "fullTitle": "Connectors .each() - iterate over an array of elements",
      "duration": 2075,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".its() - get properties on the current subject",
      "fullTitle": "Connectors .its() - get properties on the current subject",
      "duration": 354,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".invoke() - invoke a function on the current subject",
      "fullTitle": "Connectors .invoke() - invoke a function on the current subject",
      "duration": 284,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".spread() - spread an array as individual args to callback function",
      "fullTitle": "Connectors .spread() - spread an array as individual args to callback function",
      "duration": 290,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "invokes a callback function with the current subject",
      "fullTitle": "Connectors .then() invokes a callback function with the current subject",
      "duration": 482,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "yields the returned value to the next command",
      "fullTitle": "Connectors .then() yields the returned value to the next command",
      "duration": 301,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "yields the original subject without return",
      "fullTitle": "Connectors .then() yields the original subject without return",
      "duration": 363,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "yields the value yielded by the last Cypress command inside",
      "fullTitle": "Connectors .then() yields the value yielded by the last Cypress command inside",
      "duration": 269,
      "currentRetry": 0,
      "err": {}
    }
  ]
}
  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        8                                                                                │
  │ Passing:      8                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     6 seconds                                                                        │
  │ Spec Ran:     examples\connectors.spec.js                                                      │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\connectors.spec.js.mp4      (2 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:26       14       14        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\aliasing.spec.js                00:05        2        2        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\assertions.spec.js              00:09        9        9        -        -        - │
  ├──────────────────────────────────────────────────────────────────────────────────────────────── ┤
  │ √  examples\connectors.spec.js              00:06        8        8        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:47       33       33        -        -        -

Done in 93.69s.

使用cypress执行测试

	C:\Users\Administrator\node_modules\.bin>cypress run --reporter=json --reporter-options "toConsole=true"
	
	====================================================================================================
	  (Run Starting)	
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Cypress:    6.1.0                                                                              │
	  │ Browser:    Electron 87 (headless)                                                             │
	  │ Specs:      20 found (examples\actions.spec.js, examples\aliasing.spec.js, examples\assertions │
	  │             .spec.js, examples\connectors.spec.js, examples\cookies.spec.js, examples\cypress_ │
	  │             api.spec.js, examples\files.spec.js, examples\local_storage.spec.js, examples\loca │
	  │             tion.spec.j...)                                                                    │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	────────────────────────────────────────────────────────────────────────────────────────────────────
	  Running:  examples\actions.spec.js                                                       (1 of 20)
	{
	  "stats": {
	    "suites": 1,
	    "tests": 14,
	    "passes": 14,
	    "pending": 0,
	    "failures": 0,
	    "start": "2020-12-14T04:18:12.906Z",
	    "end": "2020-12-14T04:18:36.995Z",
	    "duration": 24089
	  },
	  "tests": [
	    {
	      "title": ".type() - type into a DOM element",
	      "fullTitle": "Actions .type() - type into a DOM element",
	      "duration": 7178,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".focus() - focus on a DOM element",
	      "fullTitle": "Actions .focus() - focus on a DOM element",
	      "duration": 1013,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".blur() - blur off a DOM element",
	      "fullTitle": "Actions .blur() - blur off a DOM element",
	      "duration": 838,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".clear() - clears an input or textarea element",
	      "fullTitle": "Actions .clear() - clears an input or textarea element",
	      "duration": 793,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".submit() - submit a form",
	      "fullTitle": "Actions .submit() - submit a form",
	      "duration": 668,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".click() - click on a DOM element",
	      "fullTitle": "Actions .click() - click on a DOM element",
	      "duration": 2423,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".dblclick() - double click on a DOM element",
	      "fullTitle": "Actions .dblclick() - double click on a DOM element",
	      "duration": 426,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".rightclick() - right click on a DOM element",
	      "fullTitle": "Actions .rightclick() - right click on a DOM element",
	      "duration": 542,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".check() - check a checkbox or radio element",
	      "fullTitle": "Actions .check() - check a checkbox or radio element",
	      "duration": 1305,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".uncheck() - uncheck a checkbox element",
	      "fullTitle": "Actions .uncheck() - uncheck a checkbox element",
	      "duration": 1147,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".select() - select an option in a <select> element",
	      "fullTitle": "Actions .select() - select an option in a <select> element",
	      "duration": 1180,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".scrollIntoView() - scroll an element into view",
	      "fullTitle": "Actions .scrollIntoView() - scroll an element into view",
	      "duration": 459,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".trigger() - trigger an event on a DOM element",
	      "fullTitle": "Actions .trigger() - trigger an event on a DOM element",
	      "duration": 560,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "cy.scrollTo() - scroll the window or element to a position",
	      "fullTitle": "Actions cy.scrollTo() - scroll the window or element to a position",
	      "duration": 2525,
	      "currentRetry": 0,
	      "err": {}
	    }
	  ],
	  "pending": [],
	  "failures": [],
	  "passes": [
	    {
	      "title": ".type() - type into a DOM element",
	      "fullTitle": "Actions .type() - type into a DOM element",
	      "duration": 7178,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".focus() - focus on a DOM element",
	      "fullTitle": "Actions .focus() - focus on a DOM element",
	      "duration": 1013,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".blur() - blur off a DOM element",
	      "fullTitle": "Actions .blur() - blur off a DOM element",
	      "duration": 838,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".clear() - clears an input or textarea element",
	      "fullTitle": "Actions .clear() - clears an input or textarea element",
	      "duration": 793,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".submit() - submit a form",
	      "fullTitle": "Actions .submit() - submit a form",
	      "duration": 668,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".click() - click on a DOM element",
	      "fullTitle": "Actions .click() - click on a DOM element",
	      "duration": 2423,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".dblclick() - double click on a DOM element",
	      "fullTitle": "Actions .dblclick() - double click on a DOM element",
	      "duration": 426,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".rightclick() - right click on a DOM element",
	      "fullTitle": "Actions .rightclick() - right click on a DOM element",
	      "duration": 542,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".check() - check a checkbox or radio element",
	      "fullTitle": "Actions .check() - check a checkbox or radio element",
	      "duration": 1305,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".uncheck() - uncheck a checkbox element",
	      "fullTitle": "Actions .uncheck() - uncheck a checkbox element",
	      "duration": 1147,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".select() - select an option in a <select> element",
	      "fullTitle": "Actions .select() - select an option in a <select> element",
	      "duration": 1180,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".scrollIntoView() - scroll an element into view",
	      "fullTitle": "Actions .scrollIntoView() - scroll an element into view",
	      "duration": 459,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".trigger() - trigger an event on a DOM element",
	      "fullTitle": "Actions .trigger() - trigger an event on a DOM element",
	      "duration": 560,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "cy.scrollTo() - scroll the window or element to a position",
	      "fullTitle": "Actions cy.scrollTo() - scroll the window or element to a position",
	      "duration": 2525,
	      "currentRetry": 0,
	      "err": {}
	    }
	  ]
	}
	  (Results)

	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Tests:        14                                                                               │
	  │ Passing:      14                                                                               │
	  │ Failing:      0                                                                                │
	  │ Pending:      0                                                                                │
	  │ Skipped:      0                                                                                │
	  │ Screenshots:  0                                                                                │
	  │ Video:        true                                                                             │
	  │ Duration:     24 seconds                                                                       │
	  │ Spec Ran:     examples\actions.spec.js                                                         │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	  (Video)
	  -  Started processing:  Compressing to 32 CRF
	  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa    (5 seconds)
	                          mples\actions.spec.js.mp4
	
	────────────────────────────────────────────────────────────────────────────────────────────────────
	
	  Running:  examples\aliasing.spec.js                                                      (2 of 20)
	{
	  "stats": {
	    "suites": 1,
	    "tests": 2,
	    "passes": 2,
	    "pending": 0,
	    "failures": 0,
	    "start": "2020-12-14T04:18:44.882Z",
	    "end": "2020-12-14T04:18:50.163Z",
	    "duration": 5281
	  },
	  "tests": [
	    {
	      "title": ".as() - alias a DOM element for later use",
	      "fullTitle": "Aliasing .as() - alias a DOM element for later use",
	      "duration": 1583,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".as() - alias a route for later use",
	      "fullTitle": "Aliasing .as() - alias a route for later use",
	      "duration": 1879,
	      "currentRetry": 0,
	      "err": {}
	    }
	  ],
	  "pending": [],
	  "failures": [],
	  "passes": [
	    {
	      "title": ".as() - alias a DOM element for later use",
	      "fullTitle": "Aliasing .as() - alias a DOM element for later use",
	      "duration": 1583,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".as() - alias a route for later use",
	      "fullTitle": "Aliasing .as() - alias a route for later use",
	      "duration": 1879,
	      "currentRetry": 0,
	      "err": {}
	    }
	  ]
	}
	  (Results)
	
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Tests:        2                                                                                │
	  │ Passing:      2                                                                                │
	  │ Failing:      0                                                                                │
	  │ Pending:      0                                                                                │
	  │ Skipped:      0                                                                                │
	  │ Screenshots:  0                                                                                │
	  │ Video:        true                                                                             │
	  │ Duration:     5 seconds                                                                        │
	  │ Spec Ran:     examples\aliasing.spec.js                                                        │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	  (Video)
	  -  Started processing:  Compressing to 32 CRF
	  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa     (1 second)
	                          mples\aliasing.spec.js.mp4
	────────────────────────────────────────────────────────────────────────────────────────────────────
	
	  Running:  examples\assertions.spec.js                                                    (3 of 20)
	{
	  "stats": {
	    "suites": 3,
	    "tests": 9,
	    "passes": 9,
	    "pending": 0,
	    "failures": 0,
	    "start": "2020-12-14T04:18:54.909Z",
	    "end": "2020-12-14T04:19:03.229Z",
	    "duration": 8320
	  },
	  "tests": [
	    {
	      "title": ".should() - make an assertion about the current subject",
	      "fullTitle": "Assertions Implicit Assertions .should() - make an assertion about the current subject",
	      "duration": 1750,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".and() - chain multiple assertions together",
	      "fullTitle": "Assertions Implicit Assertions .and() - chain multiple assertions together",
	      "duration": 300,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "expect - make an assertion about a specified subject",
	      "fullTitle": "Assertions Explicit Assertions expect - make an assertion about a specified subject",
	      "duration": 311,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "pass your own callback function to should()",
	      "fullTitle": "Assertions Explicit Assertions pass your own callback function to should()",
	      "duration": 606,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "finds element by class name regex",
	      "fullTitle": "Assertions Explicit Assertions finds element by class name regex",
	      "duration": 373,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "can throw any error",
	      "fullTitle": "Assertions Explicit Assertions can throw any error",
	      "duration": 335,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "matches unknown text between two elements",
	      "fullTitle": "Assertions Explicit Assertions matches unknown text between two elements",
	      "duration": 288,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "assert - assert shape of an object",
	      "fullTitle": "Assertions Explicit Assertions assert - assert shape of an object",
	      "duration": 271,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "retries the should callback until assertions pass",
	      "fullTitle": "Assertions Explicit Assertions retries the should callback until assertions pass",
	      "duration": 1759,
	      "currentRetry": 0,
	      "err": {}
	    }
	  ],
	  "pending": [],
	  "failures": [],
	  "passes": [
	    {
	      "title": ".should() - make an assertion about the current subject",
	      "fullTitle": "Assertions Implicit Assertions .should() - make an assertion about the current subject",
	      "duration": 1750,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": ".and() - chain multiple assertions together",
	      "fullTitle": "Assertions Implicit Assertions .and() - chain multiple assertions together",
	      "duration": 300,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "expect - make an assertion about a specified subject",
	      "fullTitle": "Assertions Explicit Assertions expect - make an assertion about a specified subject",
	      "duration": 311,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "pass your own callback function to should()",
	      "fullTitle": "Assertions Explicit Assertions pass your own callback function to should()",
	      "duration": 606,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "finds element by class name regex",
	      "fullTitle": "Assertions Explicit Assertions finds element by class name regex",
	      "duration": 373,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "can throw any error",
	      "fullTitle": "Assertions Explicit Assertions can throw any error",
	      "duration": 335,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "matches unknown text between two elements",
	      "fullTitle": "Assertions Explicit Assertions matches unknown text between two elements",
	      "duration": 288,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "assert - assert shape of an object",
	      "fullTitle": "Assertions Explicit Assertions assert - assert shape of an object",
	      "duration": 271,
	      "currentRetry": 0,
	      "err": {}
	    },
	    {
	      "title": "retries the should callback until assertions pass",
	      "fullTitle": "Assertions Explicit Assertions retries the should callback until assertions pass",
	      "duration": 1759,
	      "currentRetry": 0,
	      "err": {}
	    }
	  ]
	}
	  (Results)
	
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Tests:        9                                                                                │
	  │ Passing:      9                                                                                │
	  │ Failing:      0                                                                                │
	  │ Pending:      0                                                                                │
	  │ Skipped:      0                                                                                │
	  │ Screenshots:  0                                                                                │
	  │ Video:        true                                                                             │
	  │ Duration:     8 seconds                                                                        │
	  │ Spec Ran:     examples\assertions.spec.js                                                      │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	  (Video)
	  -  Started processing:  Compressing to 32 CRF
	  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa    (2 seconds)
	                          mples\assertions.spec.js.mp4                       
	────────────────────────────────────────────────────────────────────────────────────────────────────
	..............................................**省略部分用例**.......................................
	────────────────────────────────────────────────────────────────────────────────────────────────────
	
	────────────────────────────────────────────────────────────────────────────────────────────────────
	
	  Running:  testConfig.js                                                                 (20 of 20)
	{
	  "stats": {
	    "suites": 2,
	    "tests": 1,
	    "passes": 0,
	    "pending": 0,
	    "failures": 1,
	    "start": "2020-12-14T04:22:52.229Z",
	    "end": "2020-12-14T04:22:59.448Z",
	    "duration": 7219
	  },
	  "tests": [
	    {
	      "title": "登陆成功, 跳转到dashboard页",
	      "fullTitle": "登陆 HTML表单登陆测试 登陆成功, 跳转到dashboard页",
	      "duration": 5296,
	      "currentRetry": 0,
	      "err": {
	        "message": "Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'",
	        "name": "AssertionError",
	        "stack": "AssertionError: Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'\n    at Context.eval(http://localhost:7077/__cypress/tests?p=cypress\\integration\\testConfig.js:113:13)",
	        "sourceMappedStack": "AssertionError: Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'\n    at Context.eval(webpack:///cypress/integration/testConfig.js:18:1)",
	        "parsedStack": [
	          {
	            "message": "AssertionError: Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'",
	            "whitespace": ""
	          },
	          {
	            "function": "Context.eval",
	            "fileUrl": "http://localhost:7077/__cypress/tests?p=cypress\\integration\\testConfig.js",
	            "originalFile": "webpack:///cypress/integration/testConfig.js",
	            "relativeFile": "cypress/integration/testConfig.js",
	            "absoluteFile": "C:\\Users\\Administrator\\node_modules\\.bin/cypress/integration/testConfig.js",
	            "line": 18,
	            "column": 1,
	            "whitespace": "    "
	          }
	        ],
	        "codeFrame": {
	          "line": 18,
	          "column": 1,
	          "originalFile": "cypress/integration/testConfig.js",
	          "relativeFile": "cypress/integration/testConfig.js",
	          "absoluteFile": "C:\\Users\\Administrator\\node_modules\\.bin/cypress/integration/testConfig.js",
	          "frame": "  16 | \t\t\t// 断言,验证登陆成功则跳转到dashboard页面\n  17 | \t\t\t// 断言,验证用户名存在\n> 18 | \t\t\tcy.url().should('include', '/dashboard')\n     | ^\n  19 | \t\t\tcy.get('h1').should('contain', 'davie.yang')\n  20 | \t\t\t})\n  21 | \t\t})",
	          "language": "js"
	        }
	      }
	    }
	  ],
	  "pending": [],
	  "failures": [
	    {
	      "title": "登陆成功, 跳转到dashboard页",
	      "fullTitle": "登陆 HTML表单登陆测试 登陆成功, 跳转到dashboard页",
	      "currentRetry": 0,
	      "err": {
	        "message": "Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'",
	        "name": "AssertionError",
	        "stack": "AssertionError: Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'\n    at Context.eval(http://localhost:7077/__cypress/tests?p=cypress\\integration\\testConfig.js:113:13)",
	        "sourceMappedStack": "AssertionError: Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'\n    at Context.eval(webpack:///cypress/integration/testConfig.js:18:1)",
	        "parsedStack": [
	          {
	            "message": "AssertionError: Timed out retrying: expected 'http://localhost:7077/login' to include '/dashboard'",
	            "whitespace": ""
	          },
	          {
	            "function": "Context.eval",
	            "fileUrl": "http://localhost:7077/__cypress/tests?p=cypress\\integration\\testConfig.js",
	            "originalFile": "webpack:///cypress/integration/testConfig.js",
	            "relativeFile": "cypress/integration/testConfig.js",
	            "absoluteFile": "C:\\Users\\Administrator\\node_modules\\.bin/cypress/integration/testConfig.js",
	            "line": 18,
	            "column": 1,
	            "whitespace": "    "
	          }
	        ],
	        "codeFrame": {
	          "line": 18,
	          "column": 1,
	          "originalFile": "cypress/integration/testConfig.js",
	          "relativeFile": "cypress/integration/testConfig.js",
	          "absoluteFile": "C:\\Users\\Administrator\\node_modules\\.bin/cypress/integration/testConfig.js",
	          "frame": "  16 | \t\t\t// 断言,验证登陆成功则跳转到dashboard页面\n  17 | \t\t\t// 断言,验证用户名存在\n> 18 | \t\t\tcy.url().should('include', '/dashboard')\n     | ^\n  19 | \t\t\tcy.get('h1').should('contain', 'davie.yang')\n  20 | \t\t\t})\n  21 | \t\t})",
	          "language": "js"
	        }
	      }
	    }
	  ],
	  "passes": []
	}
	  (Results)
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ Tests:        1                                                                                │
	  │ Passing:      0                                                                                │
	  │ Failing:      1                                                                                │
	  │ Pending:      0                                                                                │
	  │ Skipped:      0                                                                                │
	  │ Screenshots:  1                                                                                │
	  │ Video:        true                                                                             │
	  │ Duration:     7 seconds                                                                        │
	  │ Spec Ran:     testConfig.js                                                                    │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	  (Screenshots)
	  -  C:\Users\Administrator\node_modules\.bin\cypress\screenshots\testConfig.js\登陆…     (1280x720)
	      HTML表单登陆测试 -- 登陆成功, 跳转到dashboard页 (failed).png
	  (Video)
	  -  Started processing:  Compressing to 32 CRF
	  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\tes     (1 second)
	                          tConfig.js.mp4
	====================================================================================================
	  (Run Finished)
	
	       Spec                                              Tests  Passing  Failing  Pending  Skipped
	  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
	  │ √  examples\actions.spec.js                 00:24       14       14        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\aliasing.spec.js                00:05        2        2        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\assertions.spec.js              00:08        9        9        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\connectors.spec.js              00:09        8        8        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\cookies.spec.js                 00:05        5        5        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\cypress_api.spec.js             00:09       12       12        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\files.spec.js                   00:08        4        4        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\local_storage.spec.js           00:04        1        1        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\location.spec.js                00:04        3        3        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\misc.spec.js                    00:10        6        6        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\navigation.spec.js              00:08        3        3        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\network_requests.spec.js        00:14        6        6        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\querying.spec.js                00:06        5        5        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\spies_stubs_clocks.spec.js      00:08        7        7        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\traversal.spec.js               00:12       18       18        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\utilities.spec.js               00:09        6        6        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\viewport.spec.js                00:10        1        1        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\waiting.spec.js                 00:10        2        2        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ √  examples\window.spec.js                  00:04        3        3        -        -        - │
	  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
	  │ ×  testConfig.js                            00:07        1        -        1        -        - │
	  └────────────────────────────────────────────────────────────────────────────────────────────────┘
	    ×  1 of 20 failed (5%)                      03:03      116      115        1        -        -

使用npm执行测试

D:\Cypress>npm run cypress:run --reporter=json --reporter-options "toConsole=true"

> davieyang@1.0.0 cypress:run D:\Cypress
> cypress run "toConsole=true"



====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      1 found (examples\actions.spec.js)                                                 │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 1)


  Actions
    √ .type() - type into a DOM element (7657ms)
    √ .focus() - focus on a DOM element (843ms)
    √ .blur() - blur off a DOM element (959ms)
    √ .clear() - clears an input or textarea element (984ms)
    √ .submit() - submit a form (741ms)
    √ .click() - click on a DOM element (2826ms)
    √ .dblclick() - double click on a DOM element (814ms)
    √ .rightclick() - right click on a DOM element (537ms)
    √ .check() - check a checkbox or radio element (1645ms)
    √ .uncheck() - uncheck a checkbox element (1569ms)
    √ .select() - select an option in a <select> element (1325ms)
    √ .scrollIntoView() - scroll an element into view (718ms)
    √ .trigger() - trigger an event on a DOM element (493ms)
    √ cy.scrollTo() - scroll the window or element to a position (2525ms)


  14 passing (28s)


  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     27 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (8 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:27       14       14        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:27       14       14        -        -        -

执行结果并没有打印出json,说明使用npm执行cypress用例的时候,命令行的参数并未生效,因此也不难推断出上一种用例形式--reporter=sepc,npm在执行的时候也并非因为这个命令行参数的存在而生成的spec形式的报告,而是默认就是这样的形式,要让npm执行用例的时候也能够产生多种形式的结果,需要将报告的形式设置写入到cypress.json文件中,例如要实现本例中同样的效果,则在cypress.json文件中写入如下内容

{
  "reporter": "json",
  "reporterOptions": { 
    "toConsole": true
  }
}

然后再次使用npm执行用例且无需再在命令添加参数,yarn和cypress执行用例也同样生效

D:\Cypress>npm run cypress:run

> davieyang@1.0.0 cypress:run D:\Cypress
> cypress run



====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      1 found (examples\actions.spec.js)                                                 │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 1)
{
  "stats": {
    "suites": 1,
    "tests": 14,
    "passes": 14,
    "pending": 0,
    "failures": 0,
    "start": "2020-12-27T12:38:42.137Z",
    "end": "2020-12-27T12:39:08.280Z",
    "duration": 26143
  },
  "tests": [
    {
      "title": ".type() - type into a DOM element",
      "fullTitle": "Actions .type() - type into a DOM element",
      "duration": 8266,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".focus() - focus on a DOM element",
      "fullTitle": "Actions .focus() - focus on a DOM element",
      "duration": 472,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".blur() - blur off a DOM element",
      "fullTitle": "Actions .blur() - blur off a DOM element",
      "duration": 877,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".clear() - clears an input or textarea element",
      "fullTitle": "Actions .clear() - clears an input or textarea element",
      "duration": 1039,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".submit() - submit a form",
      "fullTitle": "Actions .submit() - submit a form",
      "duration": 799,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".click() - click on a DOM element",
      "fullTitle": "Actions .click() - click on a DOM element",
      "duration": 2565,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".dblclick() - double click on a DOM element",
      "fullTitle": "Actions .dblclick() - double click on a DOM element",
      "duration": 653,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".rightclick() - right click on a DOM element",
      "fullTitle": "Actions .rightclick() - right click on a DOM element",
      "duration": 536,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".check() - check a checkbox or radio element",
      "fullTitle": "Actions .check() - check a checkbox or radio element",
      "duration": 1415,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".uncheck() - uncheck a checkbox element",
      "fullTitle": "Actions .uncheck() - uncheck a checkbox element",
      "duration": 1291,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".select() - select an option in a <select> element",
      "fullTitle": "Actions .select() - select an option in a <select> element",
      "duration": 1366,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".scrollIntoView() - scroll an element into view",
      "fullTitle": "Actions .scrollIntoView() - scroll an element into view",
      "duration": 529,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".trigger() - trigger an event on a DOM element",
      "fullTitle": "Actions .trigger() - trigger an event on a DOM element",
      "duration": 533,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "cy.scrollTo() - scroll the window or element to a position",
      "fullTitle": "Actions cy.scrollTo() - scroll the window or element to a position",
      "duration": 2481,
      "currentRetry": 0,
      "err": {}
    }
  ],
  "pending": [],
  "failures": [],
  "passes": [
    {
      "title": ".type() - type into a DOM element",
      "fullTitle": "Actions .type() - type into a DOM element",
      "duration": 8266,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".focus() - focus on a DOM element",
      "fullTitle": "Actions .focus() - focus on a DOM element",
      "duration": 472,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".blur() - blur off a DOM element",
      "fullTitle": "Actions .blur() - blur off a DOM element",
      "duration": 877,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".clear() - clears an input or textarea element",
      "fullTitle": "Actions .clear() - clears an input or textarea element",
      "duration": 1039,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".submit() - submit a form",
      "fullTitle": "Actions .submit() - submit a form",
      "duration": 799,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".click() - click on a DOM element",
      "fullTitle": "Actions .click() - click on a DOM element",
      "duration": 2565,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".dblclick() - double click on a DOM element",
      "fullTitle": "Actions .dblclick() - double click on a DOM element",
      "duration": 653,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".rightclick() - right click on a DOM element",
      "fullTitle": "Actions .rightclick() - right click on a DOM element",
      "duration": 536,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".check() - check a checkbox or radio element",
      "fullTitle": "Actions .check() - check a checkbox or radio element",
      "duration": 1415,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".uncheck() - uncheck a checkbox element",
      "fullTitle": "Actions .uncheck() - uncheck a checkbox element",
      "duration": 1291,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".select() - select an option in a <select> element",
      "fullTitle": "Actions .select() - select an option in a <select> element",
      "duration": 1366,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".scrollIntoView() - scroll an element into view",
      "fullTitle": "Actions .scrollIntoView() - scroll an element into view",
      "duration": 529,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": ".trigger() - trigger an event on a DOM element",
      "fullTitle": "Actions .trigger() - trigger an event on a DOM element",
      "duration": 533,
      "currentRetry": 0,
      "err": {}
    },
    {
      "title": "cy.scrollTo() - scroll the window or element to a position",
      "fullTitle": "Actions cy.scrollTo() - scroll the window or element to a position",
      "duration": 2481,
      "currentRetry": 0,
      "err": {}
    }
  ]
}
  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     26 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (8 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:26       14       14        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:26       14       14        -        -        -

在cypress.json文件中的处理方式更加科学,一方面无论是用yarn还是cypress还是npm都生效,另外也减少了命令行的输入

junit报告

它输出一个xml文件,用法跟之前的一样,只需要在cypress run命令后加上--reporter=junit参数即可,执行结果如下

使用yarn执行测试


D:\Cypress>yarn cypress:run --reporter=junit --reporter-options "toConsole=true"
yarn run v1.22.10
$ cypress run --reporter=junit --reporter-options toConsole=true


====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      1 found (examples\actions.spec.js)                                                 │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 1)
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="22.5900" tests="14" failures="0">
  <testsuite name="Root Suite" timestamp="2020-12-27T13:12:52" tests="0" file="cypress\integration\examples\actions.spec.js" time="0.0000" failures="0">
  </testsuite>
  <testsuite name="Actions" timestamp="2020-12-27T13:12:52" tests="14" time="22.5900" failures="0">
    <testcase name="Actions .type() - type into a DOM element" time="7.5310" classname=".type() - type into a DOM element">
    </testcase>
    <testcase name="Actions .focus() - focus on a DOM element" time="0.7680" classname=".focus() - focus on a DOM element">
    </testcase>
    <testcase name="Actions .blur() - blur off a DOM element" time="0.7380" classname=".blur() - blur off a DOM element">
    </testcase>
    <testcase name="Actions .clear() - clears an input or textarea element" time="0.8360" classname=".clear() - clears an input or textarea element">
    </testcase>
    <testcase name="Actions .submit() - submit a form" time="0.7740" classname=".submit() - submit a form">
    </testcase>
    <testcase name="Actions .click() - click on a DOM element" time="2.8300" classname=".click() - click on a DOM element">
    </testcase>
    <testcase name="Actions .dblclick() - double click on a DOM element" time="0.5650" classname=".dblclick() - double click on a DOM element">
    </testcase>
    <testcase name="Actions .rightclick() - right click on a DOM element" time="0.7260" classname=".rightclick() - right click on a DOM element">
    </testcase>
    <testcase name="Actions .check() - check a checkbox or radio element" time="1.5870" classname=".check() - check a checkbox or radio element">
    </testcase>
    <testcase name="Actions .uncheck() - uncheck a checkbox element" time="1.2820" classname=".uncheck() - uncheck a checkbox element">
    </testcase>
    <testcase name="Actions .select() - select an option in a &lt;select&gt; element" time="1.3750" classname=".select() - select an option in a &lt;select&gt; element">
    </testcase>
    <testcase name="Actions .scrollIntoView() - scroll an element into view" time="0.6290" classname=".scrollIntoView() - scroll an element into view">
    </testcase>
    <testcase name="Actions .trigger() - trigger an event on a DOM element" time="0.5020" classname=".trigger() - trigger an event on a DOM element">
    </testcase>
    <testcase name="Actions cy.scrollTo() - scroll the window or element to a position" time="2.4470" classname="cy.scrollTo() - scroll the window or element to a position">
    </testcase>
  </testsuite>
</testsuites>

  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     25 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (8 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:25       14       14        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:25       14       14        -        -        -

Done in 51.08s.
将结果写入文件
D:\Cypress>yarn cypress:run --reporter=junit --reporter-options "mochaFile=results/test-output.xml"
yarn run v1.22.10
$ cypress run --reporter=junit --reporter-options mochaFile=results/test-output.xml


====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      1 found (examples\actions.spec.js)                                                 │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 1)

  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     27 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (8 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:27       14       14        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:27       14       14        -        -        -

Done in 52.13s.

自动化测试框架[Cypress内置测试报告详解]_junit报告

使用cypress执行测试

参数的使用方式是一样的

C:\Users\Administrator\node_modules\.bin>cypress run --reporter=junit --reporter-options "mochaFile=results/test-output.xml"


====================================================================================================
  (Run Starting)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    6.1.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      20 found (examples\actions.spec.js, examples\aliasing.spec.js, examples\assertions │
  │             .spec.js, examples\connectors.spec.js, examples\cookies.spec.js, examples\cypress_ │
  │             api.spec.js, examples\files.spec.js, examples\local_storage.spec.js, examples\loca │
  │             tion.spec.j...)                                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
  Running:  examples\actions.spec.js                                                       (1 of 20)
  (Results)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     22 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
  (Video)
  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa    (7 seconds)
                          mples\actions.spec.js.mp4
────────────────────────────────────────────────────────────────────────────────────────────────────
  Running:  examples\aliasing.spec.js                                                      (2 of 20)
  (Results)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        2                                                                                │
  │ Passing:      2                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     6 seconds                                                                        │
  │ Spec Ran:     examples\aliasing.spec.js                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
  (Video)
  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa     (1 second)
                          mples\aliasing.spec.js.mp4
────────────────────────────────────────────────────────────────────────────────────────────────────
  Running:  examples\assertions.spec.js                                                    (3 of 20)
  (Results)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        9                                                                                │
  │ Passing:      9                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     8 seconds                                                                        │
  │ Spec Ran:     examples\assertions.spec.js                                                      │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
  (Video)
  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa    (3 seconds)
                          mples\assertions.spec.js.mp4
────────────────────────────────────────────────────────────────────────────────────────────────────
  Running:  examples\connectors.spec.js                                                    (4 of 20)
  (Results)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        8                                                                                │
  │ Passing:      8                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     6 seconds                                                                        │
  │ Spec Ran:     examples\connectors.spec.js                                                      │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
  (Video)
  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\exa     (1 second)
                          mples\connectors.spec.js.mp4
────────────────────────────────────────────────────────────────────────────────────────────────────
..............................................**省略部分用例**.......................................
────────────────────────────────────────────────────────────────────────────────────────────────────

────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  testConfig.js                                                                 (20 of 20)
  (Results)
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      0                                                                                │
  │ Failing:      1                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  1                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     7 seconds                                                                        │
  │ Spec Ran:     testConfig.js                                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
  (Screenshots)
  -  C:\Users\Administrator\node_modules\.bin\cypress\screenshots\testConfig.js\登陆…     (1280x720)
      HTML表单登陆测试 -- 登陆成功, 跳转到dashboard页 (failed).png
  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: C:\Users\Administrator\node_modules\.bin\cypress\videos\tes     (1 second)
                          tConfig.js.mp4
====================================================================================================
  (Run Finished)
       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ √  examples\actions.spec.js                 00:22       14       14        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\aliasing.spec.js                00:06        2        2        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\assertions.spec.js              00:08        9        9        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\connectors.spec.js              00:06        8        8        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\cookies.spec.js                 00:06        5        5        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\cypress_api.spec.js             00:07       12       12        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\files.spec.js                   00:06        4        4        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\local_storage.spec.js           00:05        1        1        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\location.spec.js                00:03        3        3        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\misc.spec.js                    00:10        6        6        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\navigation.spec.js              00:07        3        3        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\network_requests.spec.js        00:13        6        6        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\querying.spec.js                00:06        5        5        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\spies_stubs_clocks.spec.js      00:07        7        7        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\traversal.spec.js               00:10       18       18        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\utilities.spec.js               00:07        6        6        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\viewport.spec.js                00:08        1        1        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\waiting.spec.js                 00:10        2        2        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ √  examples\window.spec.js                  00:03        3        3        -        -        - │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ×  testConfig.js                            00:07        1        -        1        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ×  1 of 20 failed (5%)                      02:47      116      115        1        -        -

使用npm执行测试

修改cypress.json文件,写入如下内容

{

  "reporter": "junit",
  "reporterOptions": {
    "mochaFile": "results/test_report_[hash].xml", 
    "toConsole": true
  }
}

执行测试

D:\Cypress>npm run cypress:run

> davieyang@1.0.0 cypress:run D:\Cypress
> cypress run



====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      1 found (examples\actions.spec.js)                                                 │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 1)
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="23.4190" tests="14" failures="0">
  <testsuite name="Root Suite" timestamp="2020-12-27T13:32:28" tests="0" file="cypress\integration\examples\actions.spec.js" time="0.0000" failures="0">
  </testsuite>
  <testsuite name="Actions" timestamp="2020-12-27T13:32:28" tests="14" time="23.4190" failures="0">
    <testcase name="Actions .type() - type into a DOM element" time="8.6330" classname=".type() - type into a DOM element">
    </testcase>
    <testcase name="Actions .focus() - focus on a DOM element" time="0.9770" classname=".focus() - focus on a DOM element">
    </testcase>
    <testcase name="Actions .blur() - blur off a DOM element" time="0.7820" classname=".blur() - blur off a DOM element">
    </testcase>
    <testcase name="Actions .clear() - clears an input or textarea element" time="0.8830" classname=".clear() - clears an input or textarea element">
    </testcase>
    <testcase name="Actions .submit() - submit a form" time="0.7730" classname=".submit() - submit a form">
    </testcase>
    <testcase name="Actions .click() - click on a DOM element" time="2.6180" classname=".click() - click on a DOM element">
    </testcase>
    <testcase name="Actions .dblclick() - double click on a DOM element" time="0.5100" classname=".dblclick() - double click on a DOM element">
    </testcase>
    <testcase name="Actions .rightclick() - right click on a DOM element" time="0.5360" classname=".rightclick() - right click on a DOM element">
    </testcase>
    <testcase name="Actions .check() - check a checkbox or radio element" time="1.4510" classname=".check() - check a checkbox or radio element">
    </testcase>
    <testcase name="Actions .uncheck() - uncheck a checkbox element" time="1.2650" classname=".uncheck() - uncheck a checkbox element">
    </testcase>
    <testcase name="Actions .select() - select an option in a &lt;select&gt; element" time="1.4020" classname=".select() - select an option in a &lt;select&gt; element">
    </testcase>
    <testcase name="Actions .scrollIntoView() - scroll an element into view" time="0.5810" classname=".scrollIntoView() - scroll an element into view">
    </testcase>
    <testcase name="Actions .trigger() - trigger an event on a DOM element" time="0.4780" classname=".trigger() - trigger an event on a DOM element">
    </testcase>
    <testcase name="Actions cy.scrollTo() - scroll the window or element to a position" time="2.5300" classname="cy.scrollTo() - scroll the window or element to a position">
    </testcase>
  </testsuite>
</testsuites>

  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     26 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (8 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:26       14       14        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:26       14       14        -        -        -

自动化测试框架[Cypress内置测试报告详解]_json报告_02

可以看出结果打印到控制台,并且根据配置生成了带有哈希值的报告,它保证了唯一性


D:\Cypress>yarn cypress:run
yarn run v1.22.10
$ cypress run


====================================================================================================

  (Run Starting)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Cypress:    6.2.0                                                                              │
  │ Browser:    Electron 87 (headless)                                                             │
  │ Specs:      1 found (examples\actions.spec.js)                                                 │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


────────────────────────────────────────────────────────────────────────────────────────────────── ──

  Running:  examples\actions.spec.js                                                        (1 of 1)
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="24.8870" tests="14" failures="0">
  <testsuite name="Root Suite" timestamp="2020-12-27T13:36:45" tests="0" file="cypress\integration\examples\actions.spec.js" time="0.0000" failures="0">
  </testsuite>
  <testsuite name="Actions" timestamp="2020-12-27T13:36:45" tests="14" time="24.8870" failures="0">
    <testcase name="Actions .type() - type into a DOM element" time="8.2670" classname=".type() - type into a DOM element">
    </testcase>
    <testcase name="Actions .focus() - focus on a DOM element" time="1.4810" classname=".focus() - focus on a DOM element">
    </testcase>
    <testcase name="Actions .blur() - blur off a DOM element" time="0.8890" classname=".blur() - blur off a DOM element">
    </testcase>
    <testcase name="Actions .clear() - clears an input or textarea element" time="0.8650" classname=".clear() - clears an input or textarea element">
    </testcase>
    <testcase name="Actions .submit() - submit a form" time="0.8360" classname=".submit() - submit a form">
    </testcase>
    <testcase name="Actions .click() - click on a DOM element" time="3.0610" classname=".click() - click on a DOM element">
    </testcase>
    <testcase name="Actions .dblclick() - double click on a DOM element" time="0.6670" classname=".dblclick() - double click on a DOM element">
    </testcase>
    <testcase name="Actions .rightclick() - right click on a DOM element" time="0.6290" classname=".rightclick() - right click on a DOM element">
    </testcase>
    <testcase name="Actions .check() - check a checkbox or radio element" time="1.4500" classname=".check() - check a checkbox or radio element">
    </testcase>
    <testcase name="Actions .uncheck() - uncheck a checkbox element" time="1.3300" classname=".uncheck() - uncheck a checkbox element">
    </testcase>
    <testcase name="Actions .select() - select an option in a &lt;select&gt; element" time="1.5890" classname=".select() - select an option in a &lt;select&gt; element">
    </testcase>
    <testcase name="Actions .scrollIntoView() - scroll an element into view" time="0.5450" classname=".scrollIntoView() - scroll an element into view">
    </testcase>
    <testcase name="Actions .trigger() - trigger an event on a DOM element" time="0.7250" classname=".trigger() - trigger an event on a DOM element">
    </testcase>
    <testcase name="Actions cy.scrollTo() - scroll the window or element to a position" time="2.5530" classname="cy.scrollTo() - scroll the window or element to a position">
    </testcase>
  </testsuite>
</testsuites>

  (Results)

  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ Tests:        14                                                                               │
  │ Passing:      14                                                                               │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     28 seconds                                                                       │
  │ Spec Ran:     examples\actions.spec.js                                                         │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘


  (Video)

  -  Started processing:  Compressing to 32 CRF
  -  Finished processing: D:\Cypress\cypress\videos\examples\actions.spec.js.mp4         (9 seconds)


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped
  ┌──────────────────────────────────────────────────────────────────────────────────────────────── ┐
  │ √  examples\actions.spec.js                 00:28       14       14        -        -        - │
  └──────────────────────────────────────────────────────────────────────────────────────────────── ┘
    √  All specs passed!                        00:28       14       14        -        -        -

Done in 56.38s.

在cypress.json文件中写入配置的处理方式更加科学,一方面无论是用yarn执行还是cypress执行亦或是npm执行都生效,另一方面也减少了命令行的输入,降低了出错的概率