DatasetMissing error when using a function inside with
#546
-
Hey, I'm trying to run this code: it('will pass if decoded hashid exists', function (string $value, bool $expectedResult) {
employee();
$result = (new ExistsWithDecodedHashid('users', 'id'))->passes('id', $value);
expect($result)->toBe($expectedResult);
})->with([
[\Hashids::encode(1), true],
['1', false],
]); But I get this error:
It appears the I tried this and it works when testing individually but will fail when running all tests together: ->with([
[fn (): string => \Hashids::encode(1), true],
['1', false],
]); Although with this approach the test title will become:
Which isn't ideal. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It looks like you're calling In your case, assuming it's a facade, the container hasn't been bound at this point, so you could either resolve it as you've already done (but provide a name for the dataset entry), or use Bound Datasets. I'm wondering if we could maybe catch exceptions in dataset resolution and provide a cleaner / more helpful error message, as I too experienced this the other day. |
Beta Was this translation helpful? Give feedback.
It looks like you're calling
\Hashids
with a static method, so I'm assuming you've aliased this class as a facade? It's very likely that this is throwing an error or exception, which means the dataset can't be resolved.In your case, assuming it's a facade, the container hasn't been bound at this point, so you could either resolve it as you've already done (but provide a name for the dataset entry), or use Bound Datasets.
I'm wondering if we could maybe catch exceptions in dataset resolution and provide a cleaner / more helpful error message, as I too experienced this the other day.