Cypress: run only one test

前端 未结 6 1219
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 07:04

I want to toggle only running one test, so I don\'t have to wait for my other tests to see the result of one test.

Currently, I comment out my other tests, but this is r

6条回答
  •  梦毁少年i
    2021-01-31 07:32

    to run only one file

    cypress run --spec path/to/file.spec.js
    

    or using glob patterns:

    cypress run --spec 'path/to/files/*.spec.js'
    

    Note: you need to wrap your glob patterns in single quotes to avoid shell expansion!

    to run only one test in a file

    You can use a .only as described in the Cypress docs

    it.only('only run this one', () => {
      // similarly use it.skip(...) to skip a test
    })
    
    it('not this one', () => {
    })
    

    Also, you can do the same with describe and context blocks

    edit:

    there's also a nice VSCode extension to make adding/removing .only's easier with keyboard shortcuts. It's called Test Utils (works with js, coffee, and typescript):

提交回复
热议问题