-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(bun/test): Allow functions as first arg to describe
blocks
#17218
base: main
Are you sure you want to change the base?
feat(bun/test): Allow functions as first arg to describe
blocks
#17218
Conversation
…n. Updated types for describe. Implemented a test
nice, i think you should also make a test that runs |
Great suggestion - just added additional testing against the name |
describe
blocks
}); | ||
|
||
test("both blocks should have run", () => { | ||
expect(functionBlockRan).toBeTrue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use jest.fn
to create a mock, then use expect(fn).toHaveBeenCalled()
@@ -1725,7 +1725,7 @@ inline fn createScope( | |||
var function = if (args.len > 1) args[1] else .zero; | |||
var options = if (args.len > 2) args[2] else .zero; | |||
|
|||
if (description.isEmptyOrUndefinedOrNull() or !description.isString()) { | |||
if (description.isEmptyOrUndefinedOrNull() or (description.isFunction() and description.getName(globalThis).isEmpty())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if
describe(MyClass, function testMyClass() {
// ...
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also interested in how far Jest goes with this too
test("describe block shows function name correctly in test output", async () => { | ||
const test_dir = tmpdirSync(); | ||
try { | ||
await writeFile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll find tempDirWithFiles
useful here
What does this PR do?
Allows user to pass a function as the first argument to
describe.
fixes #17100Before these changes if you pass a function you:
How did you verify your code works?
I wrote a passing test at
test/js/bun/test/describe.test.ts