Skip to content

Commit 70b7f82

Browse files
authored
Merge branch 'main' into @invertase/dart
2 parents a904a2a + 2e02bf6 commit 70b7f82

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

src/apptesting/parseTestFiles.spec.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,24 @@ describe("parseTestFiles", () => {
6868
]);
6969
});
7070

71+
it("ignores non-yaml files", async () => {
72+
writeFile(
73+
"my_test.yaml",
74+
stringify({
75+
tests: [{ displayName: "my test", steps: [{ goal: "click a button" }] }],
76+
}),
77+
);
78+
writeFile(
79+
"my_test.txt",
80+
stringify({
81+
tests: [{ displayName: "should not be parsed", steps: [{ goal: "do nothing" }] }],
82+
}),
83+
);
84+
const tests = await parseTestFiles(tempdir.name, "http://www.foo.com");
85+
expect(tests.length).to.equal(1);
86+
expect(tests[0].testCase.displayName).to.equal("my test");
87+
});
88+
7189
it("parses the sample test case file", async () => {
7290
writeFile("smoke_test.yaml", readTemplateSync("init/apptesting/smoke_test.yaml"));
7391
const tests = await parseTestFiles(tempdir.name, "http://www.foo.com");
@@ -181,39 +199,39 @@ describe("parseTestFiles", () => {
181199
}
182200

183201
it("returns an empty list if no match", async () => {
184-
writeFile("aaa", createBasicTest(["axx", "ayy", "azz"]));
185-
writeFile("bbb", createBasicTest(["bxx", "byy", "bzz"]));
202+
writeFile("aaa.yaml", createBasicTest(["axx", "ayy", "azz"]));
203+
writeFile("bbb.yaml", createBasicTest(["bxx", "byy", "bzz"]));
186204
expect(await getTestCaseNames("yyy")).to.eql([]);
187205
});
188206

189207
it("filters on filename", async () => {
190-
writeFile("aaa", createBasicTest(["axx", "ayy", "azz"]));
191-
writeFile("bbb", createBasicTest(["bxx", "byy", "bzz"]));
208+
writeFile("aaa.yaml", createBasicTest(["axx", "ayy", "azz"]));
209+
writeFile("bbb.yaml", createBasicTest(["bxx", "byy", "bzz"]));
192210
expect(await getTestCaseNames("aaa")).to.eql(["axx", "ayy", "azz"]);
193211
});
194212

195213
it("filters on test case name", async () => {
196-
writeFile("aaa", createBasicTest(["axx", "ayy", "azz"]));
197-
writeFile("bbb", createBasicTest(["bxx", "byy", "bzz"]));
214+
writeFile("aaa.yaml", createBasicTest(["axx", "ayy", "azz"]));
215+
writeFile("bbb.yaml", createBasicTest(["bxx", "byy", "bzz"]));
198216
expect(await getTestCaseNames("", ".xx")).to.eql(["axx", "bxx"]);
199217
});
200218

201219
it("filters on filename and test case name", async () => {
202-
writeFile("aaa", createBasicTest(["axx", "ayy", "azz"]));
203-
writeFile("bbb", createBasicTest(["bxx", "byy", "bzz"]));
204-
expect(await getTestCaseNames("a$", "xx")).to.eql(["axx"]);
220+
writeFile("aaa.yaml", createBasicTest(["axx", "ayy", "azz"]));
221+
writeFile("bbb.yaml", createBasicTest(["bxx", "byy", "bzz"]));
222+
expect(await getTestCaseNames("aaa\\.yaml$", "xx")).to.eql(["axx"]);
205223
});
206224

207225
it("throws an error for invalid filename regex", async () => {
208-
writeFile("aaa", createBasicTest(["axx", "ayy", "azz"]));
226+
writeFile("aaa.yaml", createBasicTest(["axx", "ayy", "azz"]));
209227
await expect(getTestCaseNames("*.txt")).to.be.rejectedWith(
210228
FirebaseError,
211229
"Invalid file pattern regex: *.txt",
212230
);
213231
});
214232

215233
it("throws an error for invalid test case name regex", async () => {
216-
writeFile("aaa", createBasicTest(["axx", "ayy", "azz"]));
234+
writeFile("aaa.yaml", createBasicTest(["axx", "ayy", "azz"]));
217235
await expect(getTestCaseNames("", "*.txt")).to.be.rejectedWith(
218236
FirebaseError,
219237
"Invalid test name pattern regex: *.txt",

src/apptesting/parseTestFiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function parseTestFilesRecursive(params: {
106106
const path = join(testDir, filename);
107107
if (dirExistsSync(path)) {
108108
results.push(...(await parseTestFilesRecursive({ testDir: path, targetUri })));
109-
} else if (fileExistsSync(path)) {
109+
} else if (fileExistsSync(path) && (path.endsWith(".yaml") || path.endsWith(".yml"))) {
110110
try {
111111
logger.debug(`Reading ${path}.`);
112112
const file = await readFileFromDirectory(testDir, filename);

0 commit comments

Comments
 (0)