Skip to content

getName() should be called with the test it is naming as context #119

@LeaVerou

Description

@LeaVerou

I had a file testing various utils with the structure:

import { foo, bar, baz } from "../src/util.js";

export default {
	tests: [
		{ name: "foo()", run: foo, tests: [...] },
		{ name: "bar()", run: bar, tests: [...] },
		// ...
	]
}

So I thought, 💡 I can just use this.run.name and generate their names!

import { foo, bar, baz } from "../src/util.js";

export default {
	getName() {
		return this.run.name + "()";
	}
	tests: [
		{ name: "foo()", run: foo, tests: [...] },
		{ name: "bar()", run: bar, tests: [...] },
		// ...
	]
}

However, this did not work because this is the top-level test, which is useless.

Same with all the other getXXX() functions.

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions