denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.06k stars 5.14k forks source link

deno test --exclude #23731

Open alexgleason opened 1 week ago

alexgleason commented 1 week ago

I would like to exclude some files with the command line, so I can skip certain tests in my CI.

It's possible to exclude certain tests with deno.json by adding a test.exclude property, but this applies to all invocations of deno test, even when you specify an excluded file directly by filename. So, I have to delete it from deno.json when I want to run those tests manually.

I couldn't find any --exclude option in deno test, but it seems like it should exist.

EDIT: It is also possible to set { ignore: true } in the test options, and even { ignore: Deno.env.get('CI') === 'true' }, eg:

Deno.test('NDatabase.query with postgres fts', { ignore: !Deno.env.get('DATABASE_URL') }, async (t) => {

This is a little better than using text.exclude in deno.json, but it only works on individual tests, not entire files. So it becomes a maintenance problem when you have a lot of tests.

bartlomieju commented 3 days ago

Seems reasonable. PRs are welcome!