https://github.com/khalid050/seaotter
Sea Otter is a testing framework :)
https://github.com/khalid050/seaotter
javascript testing typescript vscode vscode-extension
Last synced: about 2 months ago
JSON representation
Sea Otter is a testing framework :)
- Host: GitHub
- URL: https://github.com/khalid050/seaotter
- Owner: khalid050
- Created: 2023-11-27T02:01:56.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T03:33:35.000Z (over 2 years ago)
- Last Synced: 2025-04-02T05:46:36.679Z (over 1 year ago)
- Topics: javascript, testing, typescript, vscode, vscode-extension
- Language: TypeScript
- Homepage:
- Size: 160 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Sea Otter
[](https://shields.io/#your-badge)
[](https://badge.fury.io/js/seaotter)
[](https://opensource.org/licenses/MIT)
Getting started
🌊 Dive into testing with SeaOtter
Step 1: Create a configuration object with details about your test environment. Here's an example:
1) `npm i -D seaotter`
2) Get the accompanying vscode extension for a superior experience (not yet published)
```javascript
const config = {
testDirectory: "/Absolute/Path/To/Test/Directory",
fastFail: true,
random: false,
tests: ["asyncTest.js"],
};
```
Adjust the testDirectory to the absolute path of your test directory. Specify the tests you want to run in the tests array. Set fastFail to true for quicker test termination on the first failure, and toggle random to shuffle test execution order.
Step 2: Write a test
```javascript
otter.explore`Create new User ${ MyTag }`(() => {
otter.test`Login with valid credentials`(async () => {
await simulateLogin("validUsername", "validPassword");
await verifyOnHomePage();
});
test`Login with invalid credentials`(async () => {
await simulateLogin(
"invalidUsername",
"invalidPassword"
);
const a = 10;
const b = 20;
const c = 5;
expect`${a} toEqual ${a}`;
expect`${a} toBeGreaterThan ${b}`;
expect`${c} toBeLessThan ${a}`;
});
```
Step 3: Run your tests
```javascript
import { otter } from "seaotter";
import config from "./config";
otter.wadeIn(config);
(async function () {
await otter.dive();
})();
```
This method offers a straightforward way to run your tests.
Custom Test Execution using Generator (Alternative Approach)
If you prefer more control over the test execution process, you can have the otter cruise through a generator.
This approach allows you to perform additional processing after each test and before the next one begins.
The generator provides valuable metadata about each test so that you can customize your workflow!
```javascript
(async function () {
for await (const test of otter.cruise()) {
// do something with metadata
}
})();
```
If running the former way, and running tests in quiet mode you can listen for the failure events
```javascript
otter.on('testFailure', (error) => {
doSomething(error)
});
```
Using the CLI
You'll need to setup some env variables
```bash
npm i -g seaotter
```
```bash
export TEST_DIR="/absolute/path/to/test/dir"
# This is where your dive/cruise methods are used
export TEST_ENTRY="/absolute/path/to/entry"
otter
```