Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
0567d5433f | |||
dd8c8b8e11 | |||
6dc59c3157 | |||
955794f1d0 | |||
ae63a22202 | |||
62907ea111 | |||
17e24a5421 | |||
38b2602122 | |||
80fe602fbd | |||
c076875c2f | |||
7fa43ee785 | |||
e22da55523 | |||
5919f1bec7 | |||
d6959c13e9 | |||
d0c87050c0 | |||
281c203e5c | |||
30ec6c5bc2 | |||
56f4a65a1a | |||
6868a747ed | |||
1f68396aea | |||
84c5b85a3a | |||
a56319dcdb | |||
2f30e59222 | |||
3d1fdd7c79 | |||
f9f808ef5b | |||
d2cf005052 | |||
54f3eaa142 | |||
fd4e60e020 | |||
a21ce29a15 | |||
dc4695bc38 |
100
changelog.md
100
changelog.md
@ -1,5 +1,105 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-05-01 - 6.0.3 - fix(smartexpect)
|
||||||
|
Update @push.rocks/smartexpect dependency version from ^2.4.0 to ^2.4.2
|
||||||
|
|
||||||
|
- Bump @push.rocks/smartexpect package version in package.json to address minor bug fixes and improvements.
|
||||||
|
|
||||||
|
## 2025-04-30 - 6.0.2 - fix(dependencies/smartexpect)
|
||||||
|
Update @push.rocks/smartexpect dependency to ^2.4.0
|
||||||
|
|
||||||
|
- Upgraded @push.rocks/smartexpect from ^2.3.2 to ^2.4.0 in package.json to incorporate latest improvements.
|
||||||
|
|
||||||
|
## 2025-04-30 - 6.0.1 - fix(smartexpect)
|
||||||
|
Update @push.rocks/smartexpect dependency version to ^2.3.2 in package.json
|
||||||
|
|
||||||
|
- Bump @push.rocks/smartexpect from ^2.2.0 to ^2.3.2
|
||||||
|
|
||||||
|
## 2025-04-29 - 6.0.0 - BREAKING CHANGE(dependencies)
|
||||||
|
Upgrade @push.rocks/smartexpect to ^2.2.0 and bump @types/node version; remove unused expectAsync import from ts/index.ts
|
||||||
|
|
||||||
|
- Updated '@push.rocks/smartexpect' from ^1.6.1 to ^2.2.0, which may introduce breaking API changes for consumers
|
||||||
|
- Bumped '@types/node' from ^22.14.0 to ^22.15.3
|
||||||
|
- Removed redundant expectAsync import from ts/index.ts
|
||||||
|
|
||||||
|
## 2025-04-08 - 5.6.3 - fix(package.json)
|
||||||
|
Update dependency versions for smartmongo, smartrequest, tsbuild, and @types/node
|
||||||
|
|
||||||
|
- Bump @push.rocks/smartmongo from 2.0.10 to 2.0.12
|
||||||
|
- Bump @push.rocks/smartrequest from 2.0.23 to 2.1.0
|
||||||
|
- Bump @git.zone/tsbuild from 2.2.6 to 2.3.2
|
||||||
|
- Bump @types/node from 22.13.10 to 22.14.0
|
||||||
|
|
||||||
|
## 2025-04-02 - 5.6.2 - fix(package.json)
|
||||||
|
Fix formatting in package.json to correctly include the packageManager field
|
||||||
|
|
||||||
|
- Added missing comma after the keywords array
|
||||||
|
- Ensured proper inclusion of the packageManager field for consistency
|
||||||
|
|
||||||
|
## 2025-04-02 - 5.6.1 - fix(readme)
|
||||||
|
Update README: Revamp structure for features, installation, and examples
|
||||||
|
|
||||||
|
- Reorganized sections to highlight features, installation, core API, and getting started
|
||||||
|
- Updated code examples for clarity, including Node integration and web testing sections
|
||||||
|
- Standardized headings and removed extraneous documentation details
|
||||||
|
|
||||||
|
## 2025-03-17 - 5.6.0 - feat(tap)
|
||||||
|
Add explicit fail method to the Tap class for better test failure handling
|
||||||
|
|
||||||
|
- Introduced fail() method that throws a custom error message to explicitly mark test failures
|
||||||
|
- Improves clarity in test flow by giving developers a direct way to trigger error states
|
||||||
|
|
||||||
|
## 2025-03-08 - 5.5.10 - fix(node)
|
||||||
|
Removed unused jest dependency from project.
|
||||||
|
|
||||||
|
- Removed '@jest/globals' from dependencies in package.json.
|
||||||
|
- Removed unused jest import from ts_node/index.ts.
|
||||||
|
- Kept 'expect' dependency from jest library.
|
||||||
|
|
||||||
|
## 2025-03-08 - 5.5.9 - fix(dependencies)
|
||||||
|
Fix missing jest dependency in package.json and update exports in ts_node/index.ts
|
||||||
|
|
||||||
|
- Added missing '@jest/globals' dependency to package.json.
|
||||||
|
- Updated ts_node/index.ts to properly export jest along with jestExpect.
|
||||||
|
|
||||||
|
## 2025-03-08 - 5.5.8 - fix(test)
|
||||||
|
Ensure compatibility with async/await in test cases.
|
||||||
|
|
||||||
|
|
||||||
|
## 2025-03-08 - 5.5.7 - fix(dependencies)
|
||||||
|
Updated project dependencies to the latest versions for improved stability and performance.
|
||||||
|
|
||||||
|
- Updated `@push.rocks/smartexpect` to version 1.6.1.
|
||||||
|
- Updated `@push.rocks/smartfile` to version 11.2.0.
|
||||||
|
- Updated `@push.rocks/smartpromise` to version 4.2.3.
|
||||||
|
- Updated `@push.rocks/smartshell` to version 3.2.3.
|
||||||
|
- Updated `@git.zone/tsbuild` to version 2.2.6.
|
||||||
|
- Updated `@git.zone/tstest` to version 1.0.96.
|
||||||
|
- Updated `@types/node` to version 22.13.10.
|
||||||
|
|
||||||
|
## 2025-01-19 - 5.5.6 - fix(dependencies)
|
||||||
|
Update smartpromise dependency to version 4.2.0.
|
||||||
|
|
||||||
|
- Updated @push.rocks/smartpromise dependency from version 4.1.0 to 4.2.0 in package.json.
|
||||||
|
|
||||||
|
## 2025-01-19 - 5.5.5 - fix(dependencies)
|
||||||
|
Update dependencies to the latest versions to address multiple fixes.
|
||||||
|
|
||||||
|
- Updated @push.rocks/smartexpect to version ^1.4.0.
|
||||||
|
- Updated @push.rocks/smartfile to version ^11.1.5.
|
||||||
|
- Updated @push.rocks/smartpromise to version ^4.1.0.
|
||||||
|
- Updated @types/node to version ^22.10.7.
|
||||||
|
- Updated randomstring to version ^1.3.1.
|
||||||
|
|
||||||
|
## 2024-12-30 - 5.5.4 - fix(dependencies)
|
||||||
|
Update package dependencies to their latest versions.
|
||||||
|
|
||||||
|
- Updated @push.rocks/smartexpect from ^1.2.1 to ^1.3.0.
|
||||||
|
- Updated @push.rocks/smartfile from ^11.0.21 to ^11.0.23.
|
||||||
|
- Updated @push.rocks/smartshell from ^3.0.6 to ^3.2.2.
|
||||||
|
- Updated @push.rocks/smarttime from ^4.0.8 to ^4.1.1.
|
||||||
|
- Updated @types/node from ^22.9.3 to ^22.10.2.
|
||||||
|
|
||||||
## 2024-11-23 - 5.5.3 - fix(docs)
|
## 2024-11-23 - 5.5.3 - fix(docs)
|
||||||
Update description and keywords in package files for clarity
|
Update description and keywords in package files for clarity
|
||||||
|
|
||||||
|
27
package.json
27
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/tapbundle",
|
"name": "@push.rocks/tapbundle",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "5.5.3",
|
"version": "6.0.3",
|
||||||
"description": "A comprehensive testing automation library that provides a wide range of utilities and tools for TAP (Test Anything Protocol) based testing, especially suitable for projects using tapbuffer.",
|
"description": "A comprehensive testing automation library that provides a wide range of utilities and tools for TAP (Test Anything Protocol) based testing, especially suitable for projects using tapbuffer.",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist_ts/index.js",
|
".": "./dist_ts/index.js",
|
||||||
@ -30,24 +30,24 @@
|
|||||||
"@push.rocks/smartcrypto": "^2.0.4",
|
"@push.rocks/smartcrypto": "^2.0.4",
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartenv": "^5.0.12",
|
"@push.rocks/smartenv": "^5.0.12",
|
||||||
"@push.rocks/smartexpect": "^1.2.1",
|
"@push.rocks/smartexpect": "^2.4.2",
|
||||||
"@push.rocks/smartfile": "^11.0.21",
|
"@push.rocks/smartfile": "^11.2.0",
|
||||||
"@push.rocks/smartjson": "^5.0.20",
|
"@push.rocks/smartjson": "^5.0.20",
|
||||||
"@push.rocks/smartmongo": "^2.0.10",
|
"@push.rocks/smartmongo": "^2.0.12",
|
||||||
"@push.rocks/smartpath": "^5.0.18",
|
"@push.rocks/smartpath": "^5.0.18",
|
||||||
"@push.rocks/smartpromise": "^4.0.4",
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
"@push.rocks/smartrequest": "^2.0.23",
|
"@push.rocks/smartrequest": "^2.1.0",
|
||||||
"@push.rocks/smarts3": "^2.2.5",
|
"@push.rocks/smarts3": "^2.2.5",
|
||||||
"@push.rocks/smartshell": "^3.0.6",
|
"@push.rocks/smartshell": "^3.2.3",
|
||||||
"@push.rocks/smarttime": "^4.0.8",
|
"@push.rocks/smarttime": "^4.1.1",
|
||||||
"expect": "^29.7.0"
|
"expect": "^29.7.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.66",
|
"@git.zone/tsbuild": "^2.3.2",
|
||||||
"@git.zone/tsrun": "^1.2.43",
|
"@git.zone/tsrun": "^1.2.43",
|
||||||
"@git.zone/tstest": "^1.0.77",
|
"@git.zone/tstest": "^1.0.96",
|
||||||
"@types/node": "^22.9.3",
|
"@types/node": "^22.15.3",
|
||||||
"randomstring": "^1.3.0"
|
"randomstring": "^1.3.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@ -87,5 +87,6 @@
|
|||||||
"UI components",
|
"UI components",
|
||||||
"parallel testing",
|
"parallel testing",
|
||||||
"test lifecycle management"
|
"test lifecycle management"
|
||||||
]
|
],
|
||||||
|
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
|
||||||
}
|
}
|
||||||
|
3932
pnpm-lock.yaml
generated
3932
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
190
readme.md
190
readme.md
@ -2,23 +2,39 @@
|
|||||||
|
|
||||||
A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.
|
A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.
|
||||||
|
|
||||||
## Install
|
## Features
|
||||||
|
|
||||||
To install the package, execute:
|
- TAP (Test Anything Protocol) compliant output
|
||||||
|
- Support for both browser and Node.js environments
|
||||||
|
- Built-in test coordination and timing measurements
|
||||||
|
- Parallel and sequential test execution
|
||||||
|
- Pre-task support for setup operations
|
||||||
|
- Rich assertion library via `expect`
|
||||||
|
- Comprehensive Node.js tooling (shell, crypto, MongoDB, S3)
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @push.rocks/tapbundle --save-dev
|
npm install @push.rocks/tapbundle --save-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
This command will add `@push.rocks/tapbundle` to your project's `devDependencies`, ensuring it is only used during development and testing.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The `@push.rocks/tapbundle` is a versatile testing framework compatible with TAP, designed using TypeScript to facilitate robust and scalable testing of applications, whether you are dealing with unit tests, integration tests, or simply need a streamlined way to automate assertions across your application’s lifecycle. The framework is especially useful if you are already using or planning to use tapbuffer.
|
The `@push.rocks/tapbundle` is a versatile testing framework compatible with TAP, designed using TypeScript to facilitate robust and scalable testing of applications, whether you are dealing with unit tests, integration tests, or simply need a streamlined way to automate assertions across your application's lifecycle. The framework is especially useful if you are already using or planning to use tapbuffer.
|
||||||
|
|
||||||
**Getting Started**
|
### Core API
|
||||||
|
|
||||||
To begin using `tapbundle`, ensure that your TypeScript project is configured for ESM syntax. Here's how you can set it up and start writing your tests:
|
The main test runner is accessed through the `tap` object:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
tap.test(
|
||||||
|
description: string, // Test description
|
||||||
|
testFunction: async (tools?: TapTools) => Promise<any>, // Test implementation
|
||||||
|
modeArg: 'normal' | 'only' | 'skip' = 'normal' // Execution mode
|
||||||
|
): TapTest
|
||||||
|
```
|
||||||
|
|
||||||
|
### Getting Started
|
||||||
|
|
||||||
1. **Basic Setup**
|
1. **Basic Setup**
|
||||||
|
|
||||||
@ -28,11 +44,9 @@ To begin using `tapbundle`, ensure that your TypeScript project is configured fo
|
|||||||
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
||||||
```
|
```
|
||||||
|
|
||||||
Start with a simple test to ensure everything is set up correctly:
|
Start with a simple test:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { tap, expect } from '@push.rocks/tapbundle';
|
|
||||||
|
|
||||||
tap.test('Initial test succeeds', async () => {
|
tap.test('Initial test succeeds', async () => {
|
||||||
return expect(true).toBeTrue();
|
return expect(true).toBeTrue();
|
||||||
});
|
});
|
||||||
@ -40,23 +54,14 @@ To begin using `tapbundle`, ensure that your TypeScript project is configured fo
|
|||||||
tap.start();
|
tap.start();
|
||||||
```
|
```
|
||||||
|
|
||||||
The above code establishes a basic test environment, using the `tap` instance to manage execution flow and `expect` for assertions.
|
|
||||||
|
|
||||||
2. **Defining and Organizing Tests**
|
2. **Defining and Organizing Tests**
|
||||||
|
|
||||||
You can define tests using the `tap.test` method, where you provide a description and an asynchronous function:
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
tap.test('basic arithmetic test', async () => {
|
tap.test('basic arithmetic test', async () => {
|
||||||
expect(1 + 1).toEqual(2);
|
expect(1 + 1).toEqual(2);
|
||||||
});
|
});
|
||||||
```
|
|
||||||
|
|
||||||
**Async Tests Handling**
|
// Async Tests
|
||||||
|
|
||||||
Use `expectAsync` for promises or async operations:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
tap.test('async operation test', async () => {
|
tap.test('async operation test', async () => {
|
||||||
const fetchData = async () => Promise.resolve('data');
|
const fetchData = async () => Promise.resolve('data');
|
||||||
await expectAsync(fetchData()).toBeResolved();
|
await expectAsync(fetchData()).toBeResolved();
|
||||||
@ -65,62 +70,43 @@ To begin using `tapbundle`, ensure that your TypeScript project is configured fo
|
|||||||
|
|
||||||
3. **Tools for Advanced Testing**
|
3. **Tools for Advanced Testing**
|
||||||
|
|
||||||
`tapbundle` equips you with tools for sophisticated test scenarios:
|
```typescript
|
||||||
|
// Delay and Timing
|
||||||
|
tap.test('test with delay', async (tools) => {
|
||||||
|
await tools.delayFor(500); // waits for 500ms
|
||||||
|
expect(true).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
- **Delay and Timing**
|
// Custom Pre Tasks
|
||||||
|
tap.preTask('initialize environment', async () => {
|
||||||
|
console.log('Setting up preconditions');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
Integrated delay methods are handy for simulating timeouts and waiting states:
|
4. **Execution Control**
|
||||||
|
|
||||||
```typescript
|
|
||||||
tap.test('test with delay', async (tools) => {
|
|
||||||
await tools.delayFor(500); // waits for 500ms
|
|
||||||
expect(true).toBeTrue();
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Custom Pre Tasks**
|
|
||||||
|
|
||||||
Set up tasks to run before your test suite begins. This can be setup operations like initializing databases:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
tap.preTask('initialize environment', async () => {
|
|
||||||
console.log('Setting up preconditions');
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Execution and Control**
|
|
||||||
|
|
||||||
- **Running Tests**
|
|
||||||
|
|
||||||
Call `tap.start()` to execute your suite. Handle specific conditions using `.skip` or `.only`:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
tap.skip.test('skip this test', async () => {
|
|
||||||
// This test will be ignored
|
|
||||||
});
|
|
||||||
|
|
||||||
tap.only.test('run this test exclusively', async () => {
|
|
||||||
// Only this test will run among defined tests
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
- **Handling Errors and Debugging**
|
|
||||||
|
|
||||||
Make use of `consolecolor` to make outputs readable:
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
tap.test('test with colored output', async (tools) => {
|
|
||||||
const message = await tools.coloredString('Test Passed!', 'green');
|
|
||||||
console.log(message);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
5. **Integration with Node Tools**
|
|
||||||
|
|
||||||
For operations involving the shell or environment-specific setups, use Node tools provided:
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { tapNodeTools } from './ts_node/index.js';
|
// Skip tests
|
||||||
|
tap.skip.test('skip this test', async () => {
|
||||||
|
// This test will be ignored
|
||||||
|
});
|
||||||
|
|
||||||
|
// Exclusive tests
|
||||||
|
tap.only.test('run this test exclusively', async () => {
|
||||||
|
// Only this test will run
|
||||||
|
});
|
||||||
|
|
||||||
|
// Colored output
|
||||||
|
tap.test('test with colored output', async (tools) => {
|
||||||
|
const message = await tools.coloredString('Test Passed!', 'green');
|
||||||
|
console.log(message);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Node.js Integration**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { tapNodeTools } from '@push.rocks/tapbundle/node';
|
||||||
|
|
||||||
tap.test('execute shell command', async () => {
|
tap.test('execute shell command', async () => {
|
||||||
const result = await tapNodeTools.runCommand('ls -la');
|
const result = await tapNodeTools.runCommand('ls -la');
|
||||||
@ -130,13 +116,10 @@ To begin using `tapbundle`, ensure that your TypeScript project is configured fo
|
|||||||
tap.test('create HTTPS certificate', async () => {
|
tap.test('create HTTPS certificate', async () => {
|
||||||
const { key, cert } = await tapNodeTools.createHttpsCert('localhost');
|
const { key, cert } = await tapNodeTools.createHttpsCert('localhost');
|
||||||
expect(key).toInclude('-----BEGIN RSA PRIVATE KEY-----');
|
expect(key).toInclude('-----BEGIN RSA PRIVATE KEY-----');
|
||||||
expect(cert).toInclude('-----BEGIN CERTIFICATE-----');
|
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
6. **Working with Environment Variables**
|
6. **Environment Variables**
|
||||||
|
|
||||||
Leverage the power of dynamic environment management using `qenv`:
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
tap.test('use environment variable', async (tools) => {
|
tap.test('use environment variable', async (tools) => {
|
||||||
@ -145,9 +128,7 @@ To begin using `tapbundle`, ensure that your TypeScript project is configured fo
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
7. **Managing Asynchronous Behavior**
|
7. **Asynchronous Control**
|
||||||
|
|
||||||
The framework allows for precise control over asynchronous processes, introducing race conditions or coordinated delays:
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
tap.test('controlled async scenario', async (tools) => {
|
tap.test('controlled async scenario', async (tools) => {
|
||||||
@ -158,52 +139,41 @@ To begin using `tapbundle`, ensure that your TypeScript project is configured fo
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
8. **Web Testing Utilities**
|
8. **Web Testing**
|
||||||
|
|
||||||
If your testing involves browser environments, make use of the `webhelpers` utilities, for instance with libraries like Open WC:
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { webhelpers } from './webhelpers.js';
|
import { webhelpers } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
tap.test('web component test', async () => {
|
tap.test('web component test', async () => {
|
||||||
const element = await webhelpers.fixture(webhelpers.html`<my-element></my-element>`);
|
const element = await webhelpers.fixture(
|
||||||
|
webhelpers.html`<my-element></my-element>`
|
||||||
|
);
|
||||||
expect(element.shadowRoot.querySelector('div')).toBeDefined();
|
expect(element.shadowRoot.querySelector('div')).toBeDefined();
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
9. **Using Webhelpers in Browser**
|
9. **Database and Storage Testing**
|
||||||
|
|
||||||
Make the tests more interactive, especially for UI Components:
|
```typescript
|
||||||
|
tap.test('Smartmongo setup test', async () => {
|
||||||
```typescript
|
const smartmongo = await tapNodeTools.createSmartmongo();
|
||||||
tap.preTask('Setup pre-task for UI test', async () => {
|
await smartmongo.stop();
|
||||||
console.log('Setting up for UI tests');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('UI test with Web Component', async () => {
|
tap.test('Smarts3 setup', async () => {
|
||||||
const myEl = await webhelpers.fixture(webhelpers.html`<div id="myEl">Content</div>`);
|
const smarts3 = await tapNodeTools.createSmarts3();
|
||||||
expect(myEl.id).toBe('myEl');
|
console.log('Smarts3 running');
|
||||||
|
await smarts3.stop();
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
10. **Leveraging Smartmongo and Smarts3**
|
## Best Practices
|
||||||
|
|
||||||
Whether you’re working with databases or cloud storage simulations:
|
1. Use descriptive test names that explain the expected behavior
|
||||||
|
2. Leverage pre-tasks for common setup operations
|
||||||
```typescript
|
3. Use `testParallel` for independent tests that can run concurrently
|
||||||
tap.test('Smartmongo setup test', async () => {
|
4. Utilize test coordination for dependent tests
|
||||||
const smartmongo = await tapNodeTools.createSmartmongo();
|
5. Set appropriate timeouts for async operations
|
||||||
await smartmongo.stop();
|
|
||||||
});
|
|
||||||
|
|
||||||
tap.test('Smarts3 setup', async () => {
|
|
||||||
const smarts3 = await tapNodeTools.createSmarts3();
|
|
||||||
console.log('Smarts3 running');
|
|
||||||
await smarts3.stop();
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Integrating `@push.rocks/tapbundle` streamlines your test management in complex projects. With these tools, intricate scenarios from unit tests to more elaborate integrated environments become easier to handle, providing a structured flow to achieve reliable testing outcomes. Happy testing!
|
|
||||||
|
|
||||||
## License and Legal Information
|
## License and Legal Information
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/tapbundle',
|
name: '@push.rocks/tapbundle',
|
||||||
version: '5.5.3',
|
version: '6.0.3',
|
||||||
description: 'A comprehensive testing automation library that provides a wide range of utilities and tools for TAP (Test Anything Protocol) based testing, especially suitable for projects using tapbuffer.'
|
description: 'A comprehensive testing automation library that provides a wide range of utilities and tools for TAP (Test Anything Protocol) based testing, especially suitable for projects using tapbuffer.'
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@ export { tap } from './tapbundle.classes.tap.js';
|
|||||||
export { TapWrap } from './tapbundle.classes.tapwrap.js';
|
export { TapWrap } from './tapbundle.classes.tapwrap.js';
|
||||||
export { webhelpers } from './webhelpers.js';
|
export { webhelpers } from './webhelpers.js';
|
||||||
|
|
||||||
import { expect, expectAsync } from '@push.rocks/smartexpect';
|
import { expect } from '@push.rocks/smartexpect';
|
||||||
|
|
||||||
export { expect, expectAsync };
|
export { expect };
|
||||||
|
@ -160,6 +160,14 @@ export class Tap<T> {
|
|||||||
public threw(err: Error) {
|
public threw(err: Error) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicitly fail the current test with a custom message
|
||||||
|
* @param message - The failure message to display
|
||||||
|
*/
|
||||||
|
public fail(message: string = 'Test failed'): never {
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export let tap = new Tap();
|
export let tap = new Tap();
|
||||||
|
@ -60,5 +60,9 @@ export class TapTools {
|
|||||||
return plugins.smartpromise.defer();
|
return plugins.smartpromise.defer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public cumulativeDefer() {
|
||||||
|
return plugins.smartpromise.cumulativeDefer();
|
||||||
|
}
|
||||||
|
|
||||||
public smartjson = plugins.smartjson;
|
public smartjson = plugins.smartjson;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ export class TestFileProvider {
|
|||||||
// fetch the docker alpine image
|
// fetch the docker alpine image
|
||||||
const response = await plugins.smartrequest.getBinary(fileUrls.dockerAlpineImage);
|
const response = await plugins.smartrequest.getBinary(fileUrls.dockerAlpineImage);
|
||||||
await plugins.smartfile.fs.ensureDir(paths.testFilesDir);
|
await plugins.smartfile.fs.ensureDir(paths.testFilesDir);
|
||||||
const AlpineBuffer = await plugins.smartfile.memory.toFs(response.body, filePath);
|
await plugins.smartfile.memory.toFs(response.body, filePath);
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
export * from './classes.tapnodetools.js';
|
export * from './classes.tapnodetools.js';
|
||||||
|
|
||||||
import { expect as jestExpect } from 'expect';
|
import { expect as jestExpect } from 'expect';
|
||||||
|
|
||||||
export { jestExpect };
|
export { jestExpect };
|
||||||
|
Reference in New Issue
Block a user