Skip to content
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

Allow using expect from bun:test outside of bun test #8326

Closed
TomasHubelbauer opened this issue Jan 21, 2024 · 1 comment
Closed

Allow using expect from bun:test outside of bun test #8326

TomasHubelbauer opened this issue Jan 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@TomasHubelbauer
Copy link

What is the problem this feature would solve?

Allow us to use the assertion functions in runtime code.

import { expect } from 'bun:test';
expect(1).to.equal(1);

bun run test.js:

2 | expect(1).to.equal(1);
    ^
TypeError: undefined is not an object (evaluating 'expect(1).to.equal')

What is the feature you are proposing to solve the problem?

There seems to be an assumption built into expect that the bun test environment is what the function is being executed in. If that could be dropped or made optional, the except could be just a utility function.

What alternatives have you considered?

We can use Node's assert:

import assert from 'node:assert';
assert.equal(1, 1);
@TomasHubelbauer TomasHubelbauer added the enhancement New feature or request label Jan 21, 2024
@paperdave
Copy link
Collaborator

you are using the expect api wrong:

this issue used to exist but was resolved a while ago

import { expect } from 'bun:test';
expect(1).toEqual(1);

@paperdave paperdave closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants