Pest v2.16 - Native function checks, new string expectations, and more
Published on by Eric L. Barnes
Nuno Maduro announced on X that Pest v2.16 is now out. This update comes packed with native functions support on the arch plugin, fresh expectations, and more. Here is a quick example of the new features:
expect(['die', 'eval', 'sleep'])->not->toBeUsed();expect('abcDef')->toBeCamelCase();expect('abc-def')->toBeKebabCase();expect('abc_def')->toBeSnakeCase();expect('AbcDef')->toBeStudlyCase();expect('9001 ')->toBeDigits(); // failed because of the space.expect('9001')->toBeDigits(); // true
Pest Native Functions Support
You can now make sure that certain native functions aren't used in your application:
expect(['die', 'eval', 'sleep']) ->not ->toBeUsed();
Pest String Case Expectations
This means you can easily check for things like "toBeCamelCase", "toBeSnakeCase", and more:
expect('abcDef')->toBeCamelCase();expect('abc-def')->toBeKebabCase();expect('abc_def')->toBeSnakeCase();expect('AbcDef')->toBeStudlyCase();
Pest expect string to be digits
Need to verify if a given string contains only digits?
expect('9001 ')->toBeDigits(); // fails because of the space.expect('9001')->toBeDigits); // success
Eric is the creator of Laravel News and has been covering Laravel since 2012.