modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.22k stars 290 forks source link

Only run tests matching a pattern #1287

Closed arv closed 3 years ago

arv commented 3 years ago

When running the tests in a browser I run something like:

web-test-runner src/replicache.test.ts --playwright --browsers chromium firefox webkit --watch

How do I only run the test with the name "subscribe" (https://github.com/rocicorp/replicache-sdk-js/blob/main/src/replicache.test.ts#L303)

Previously I used to open a browser and use Mocha's UI to only select one test (not optimal but better than running all the tests all the time)

Maybe this is supported but I could not find any documentation about this?

LarsDenBakker commented 3 years ago

This one is complicated because the test runner boots up a browser and then mocha runs inside that. We would have to communicate this name from the CLI to mocha somehow.

We already allow focusing a single test file (using "F" and then writing the number of the test). From there on you can use it.only or test.only in mocha to run a single test. Do you think that would be sufficient for you use case?

You can also turn on the HTML reporter with this config:

export default {
  testFramework: {
    config: {
      reporter: 'html',
    },
  },
};

Now when you open a debug browser (using "D" and writing the number of the test) you get the mocha UI and you can click on a test.

arv commented 3 years ago

Using reporter: 'html' gets me back to the way it used to be and it is good enough for me.

Still would be nice to allow this on the command line though.

Also, thanks for web-test-runner. I don't know how anyone can unit test web things without this any more.

LarsDenBakker commented 3 years ago

Thanks for the compliment :) Closing this one since I think the question was answered.