Consider the following test cases:
describe("parent1", () => {
it("mytest", () => {
// ...
});
});
describe("parent2", () => {
it("mytest", () => {
// ...
});
});
describe("parent1", () => {
it("myothertest", () => {
// ...
});
});
describe("parent2", () => {
it("myothertest", () => {
// ...
});
});
I basically want to be able to run, via commandline, mytest under parent1.
If I try the following:
mocha --grep 'mytest'
It will end up running:
parent1/mytestparent2/mytestWhereas if I try:
mocha --grep 'parent1'
It will end up running:
parent1/mytestparent1/myothertestHow to achieve this?
It was actually quite simple since this is evaluated as a regex:
mocha --grep 'parent1 mytest'
Using a space is the solution it seems. I can successfully pinpoint tests like that.
It also works if test names have spaces in them:
describe("parent1", () => {
it("my test", () => {
console.log("AAA");
});
});
describe("parent2", () => {
it("my test", () => {
console.log("BBB");
});
});
describe("parent1", () => {
it("my other test", () => {
console.log("CCC");
});
});
describe("parent2", () => {
it("my other test", () => {
console.log("DDD");
});
});
Running:
mocha --grep 'parent1 my test'
Would work as expected.