Simple testing framework for JavaScript and TypeScript, written in pure JavaScript.
Documentation: https://easy.org.ua/
Core features:
- No need to import
it
,test
,describe
orecpext
in your test file. These functions are available globally. - You can use both
js
andts
test files in the same project. - Asynchronous code testing.
- TypeScript testing out of the box.
- Global DOM object for testing HTML objects.
- Built-in coverage tool.
- Verbose or non verbose mode.
- Mock functions.
- Big set of built-in matchers.
- Extend
expect
function with your own matchers. - Compatible with
codecov
report viewer. - A lot of expects in one test case.
- Setup and Teardown functions (
beforeEach
,afterEach
,beforeAll
,afterAll
).
Support for PayPal to [email protected]
npm install @olton/easytest -D
To use EasyTest
you don't need to import it
, test
or describe
in your test file.
Create a test file with *.test.js
or *.test.ts
extension (for example).
You can use both of them in the same project.
function hello() {
return "Hello"
}
describe(`Common tests suite`, () => {
it(`says hello`, () => {
return expect(hello()).toBe("Hello")
})
})
test(`Bad test 2 !== 1`, () => {
return expect(2).toBe(1)
})
async function fetchData() {
return new Promise((resolve) => {
setTimeout(() => {
resolve("Data received");
}, 1000);
});
}
describe('Async function tests', async () => {
it('should return data after 1 second', async () => {
const data = await fetchData();
return expect(data).toBe("Bad Data");
});
});
Update package.json
to run tests with easytest
command.
{
"scripts": {
"test": "easytest"
}
}
describe
- create test suiteit
- create a test casetest
- create simple testexpect
- create assertionbeforeEach
- run before each test caseafterEach
- run after each test casebeforeAll
- run before all test casesafterAll
- run after all test casesmock
- create mock function
EasyTest contains a big set of built-in matchers:
- A simple comparison
- A strong comparison
- Type checking
- Number checking
- String checking
- Array checking
- Object checking
- Color checking
- IP, Email, Url checking
- JSON, XML checking
- Date, RegExp, Symbol checking
- Function checking
- HTML element checking
- and more...
To use EasyTest
with TypeScript you need to install tsx
package.
npm install -D tsx cross-env
and then
{
"scripts": {
"test": "cross-env NODE_OPTIONS=\"--import tsx\" easytest"
}
}
EasyTest licensed under MIT license.
Use issue tracker to report bugs or request new features.
© 2024-2025 Serhii Pimenov. All rights reserved.