In my Playwright project, I need to ignore a directory and all of it's sub directories.
For example if I have the following directories tree:
tests -> fooFolder --> foo2Folder ---> fooFile2.spec.ts
fooFile1.spec.ts
barFolder --> barFile.spec.ts
In this example I need to ignore fooFolder
and all tests under it.
I tried ignore it like this:
projects: [
{
name: "bar only",
testIgnore: ["/tests/fooFolder/*.spec.ts"], // ignores only test files that directly under fooFolder
},
]
I've also tried with /tests/fooFolder//*.spec.ts
but this causes no ignore at all.
I can put an array of the sub-directories, but this is impractical.
I've found a way,
apparently, if I add /**
(glob pattern) in between /fooFolder
and /*.spec.ts
this will ignore all test file under fooFolder
and all of it's sub-directories
Code example:
projects: [
{
name: "bar only",
testIgnore: ["/tests/fooFolder/**/*.spec.ts"], // ignores all test files under fooFolder and it's sub-dirs
},
]