Skip to content

suissa/t3ster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

one-proof-4-all

One Proof 4 All

One Runner to Rule Them All

A polyglot testing framework that adds specialized dialects to existing test suites without requiring rewrites. Zero-risk adoption with Jest compatibility.

Features β€’ Installation β€’ Quick Start β€’ Dialects β€’ Documentation


🎯 Features

  • Zero Risk Adoption: Your legacy code continues working unchanged
  • Polyglot Approach: Multiple specialized dialects for different domains
  • Jest Compatible: Runs alongside existing Jest tests in the same suite
  • Four Specialized Dialects:
    • πŸ“ Mathematical: For algorithms, calculations, and mathematical proofs
    • πŸ“– Narrative: For business rules readable by product managers
    • πŸ›‘οΈ Imperative: For API contracts and integration testing
    • 🌐 API Testing: For declarative API contract validation

πŸš€ Installation

npm install @purecore/one-proof-4-all

⚑ Quick Start

Create a test file api.spec.ts:

import { ensure, check, that, stub } from "@purecore/one-proof-4-all";

ensure("My User API", () => {
  const api = stub();
  api.forceReturn({ status: 200, id: "user_123" });

  check("User creation returns 200 OK", () => {
    const response = api.createUser({ name: "John" });

    that(response.status).is(200);
    that(response.id).matches(/^user_\w+$/);
  });
});

Run your tests:

npx one-proof-4-all
# or aliases:
npx os4all
npx 1spec
npx testall

🧭 Which Dialect Is Right for You?

You don't need to learn all four. Choose what fits your domain:

                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚   What are you testing?                  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                               β”‚                               β”‚
              β–Ό                               β–Ό                               β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ Pure algorithms,     β”‚      β”‚ User flows, business β”‚      β”‚ APIs, contracts,     β”‚
   β”‚ calculations,        β”‚      β”‚ rules readable by    β”‚      β”‚ integrations,        β”‚
   β”‚ mathematical rules?  β”‚      β”‚ product managers?    β”‚      β”‚ compliance?          β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚                               β”‚                               β”‚
              β–Ό                               β–Ό                               β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ πŸ“ MATHEMATICAL      β”‚      β”‚ πŸ“– NARRATIVE         β”‚      β”‚ πŸ›‘οΈ IMPERATIVE        β”‚
   β”‚ axiom, proof, impliesβ”‚      β”‚ intend, scenario, to β”‚      β”‚ ensure, check, that  β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                                                β–Ό
                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                β”‚ Backend services, QA teams?  β”‚
                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β–Ό
                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                β”‚ 🌐 API TESTING               β”‚
                                β”‚ ApiSpec.define().post()      β”‚
                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Mathematical Dialect

Perfect for scientists and mathematicians proving pure functions.

Example

import { axiom, proof, implies } from "@purecore/one-proof-4-all";

axiom("SHA-256 Hash Theory", () => {
  proof("Empty string hash converges to known constant", () => {
    implies(sha256("")).is("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
  });
  
  proof("Hash is deterministic", () => {
    const input = "hello world";
    implies(sha256(input)).is(sha256(input));
  });
});

Key Functions

  • axiom(name, fn) - Group of truths
  • proof(name, fn) - Individual proof
  • implies(val).is(x) - Logical implication
  • arbitrary() - Generic function
  • postulate(fn) - Global premises
  • given(fn) - "Given that..."

πŸ“š Complete Mathematical API Documentation

πŸ“– Narrative Dialect

Designed for teams with product managers who need to validate business rules.

Example

import { intend, scenario, to, standIn } from "@purecore/one-proof-4-all";

intend("User Permission Journey", () => {
  const userService = standIn();
  
  background(() => {
    userService.setup({
      permissions: ["read", "write"]
    });
  });

  scenario("Unauthorized user tries to access admin panel", () => {
    const response = userService.accessAdminPanel("guest_user");
    to(response.status).be(403);
    to(response.message).be("Access denied");
  });

  scenario("Authorized user accesses dashboard", () => {
    const response = userService.accessDashboard("admin_user");
    to(response.status).be(200);
    to(response.data).toBeDefined();
  });
});

Key Functions

  • intend(name, fn) / story(name, fn) - Intent/story
  • scenario(name, fn) / detail(name, fn) - Scenario
  • to(val).be(x) - Expectation
  • standIn() / dummy() - Stand-in
  • background(fn) - Context
  • before(fn) - Before each scene

πŸ“š Complete Narrative API Documentation

πŸ›‘οΈ Imperative Dialect

For backend developers testing API contracts and integrations.

Example

import { ensure, verify, that, stub, initAll, reset } from "@purecore/one-proof-4-all";

let api;

initAll(() => {
  api = stub();
});

reset(() => {
  api.reset();
});

ensure("PCI-DSS Gateway Compliance v4", () => {
  verify("Sensitive data never travels in plain text", () => {
    const payload = api.processPayment({ card: "1234" });
    that(payload).matches(/^encrypted:/);
  });

  verify("All transactions are logged", () => {
    api.processTransaction({ amount: 100 });
    that(api.getTransactionLog()).toHaveLength(1);
  });
});

Key Functions

  • ensure(name, fn) - Ensure a requirement
  • check(name, fn) / verify(name, fn) - Point check
  • that(val).is(x) - Assertion
  • stub() / mock() - Create mock
  • initAll(fn) - Initial setup
  • reset(fn) - Reset per test
  • spy() - Monitor calls
  • disposeAll(fn) - Cleanup

πŸ“š Complete Imperative API Documentation

🌐 API Testing Dialect

Specialized for backend services and QA teams testing microservices.

Example

import { ApiSpec } from "@purecore/one-proof-4-all";

const userSchema = {
  type: "object",
  properties: {
    id: { type: "string" },
    name: { type: "string" },
    email: { type: "string", format: "email" }
  },
  required: ["id", "name", "email"]
};

await ApiSpec.define("Create User")
  .from("https://api.example.com")
  .post("/users", { 
    name: "John Doe",
    email: "john@example.com" 
  })
  .shouldReturn(201)
  .matchingSchema(userSchema)
  .run();

await ApiSpec.define("Get User")
  .from("https://api.example.com")
  .get("/users/user_123")
  .shouldReturn(200)
  .matchingSchema(userSchema)
  .run();

Key Functions

  • ApiSpec.define(name) - Define the test
  • .from(url) - Set base URL
  • .get() / .post() / .put() / .delete() - HTTP actions
  • .shouldReturn(code) - Status validation
  • .matchingSchema(schema) - Contract validation
  • .withHeaders(headers) - Set headers
  • .withAuth(token) - Authentication
  • .timeout(ms) - Set timeout

πŸ“š Complete API Testing Documentation

πŸƒ Running API Tests

  1. Create a file ending in .spec.ts (e.g., api.spec.ts)
  2. Import the dialect:
    import { ApiSpec } from "@purecore/one-proof-4-all";
  3. Define and run your test (supports Top-Level Await):
    await ApiSpec.define("Health Check")
      .from("http://localhost:3000")
      .get("/health")
      .shouldReturn(200)
      .run();
  4. Execute using the CLI:
    npx one-proof-4-all
    # or with bun
    bun run os4all

🎭 Polyglot Example: Shopping Cart

Using multiple dialects in the same project:

// πŸ“ MATHEMATICAL: Price calculations (pure logic)
import { axiom, proof, implies } from "@purecore/one-proof-4-all";

axiom("Price Calculation Theory", () => {
  proof("10% discount on $100 equals $90", () => {
    implies(calcDiscount(100, 10)).is(90);
  });
  
  proof("Tax calculation is additive", () => {
    const base = 100;
    const discounted = calcDiscount(base, 10);
    const withTax = addTax(discounted, 5);
    implies(withTax).is(94.5);
  });
});

// πŸ“– NARRATIVE: User journey (PM readable)
import { intend, scenario, to } from "@purecore/one-proof-4-all";

intend("User Shopping Journey", () => {
  scenario("User adds product to cart", () => {
    const cart = shoppingCart.addProduct(product);
    to(cart.items).toHaveLength(1);
    to(cart.total).be(29.99);
  });
  
  scenario("User applies coupon code", () => {
    const cart = shoppingCart.applyCoupon("SAVE10");
    to(cart.discount).be(10);
    to(cart.finalTotal).be(26.99);
  });
});

// πŸ›‘οΈ IMPERATIVE: Payment gateway integration (strict contract)
import { ensure, check, that } from "@purecore/one-proof-4-all";

ensure("Payment Gateway v2.1 Compliance", () => {
  check("Transaction returns status 200", () => {
    const response = paymentGateway.process({
      amount: 26.99,
      card: "**** **** **** 1234"
    });
    that(response.status).is(200);
    that(response.transactionId).matches(/^txn_[a-zA-Z0-9]+$/);
  });
  
  check("Failed transactions return proper error codes", () => {
    const response = paymentGateway.process({
      amount: 26.99,
      card: "invalid_card"
    });
    that(response.status).is(400);
    that(response.errorCode).is("INVALID_CARD");
  });
});

πŸ“ See complete polyglot example

πŸ“š Complete Documentation

Core Documentation

API References

Examples

πŸ”„ Jest Compatibility

Your existing Jest tests continue working unchanged:

// βœ… Your legacy Jest code - UNTOUCHED
describe("Login Module (Legacy)", () => {
  it("should validate password", () => {
    expect(validate("123")).toBe(true);
  });
});

// βœ… New feature with new dialect - COMPLEMENTARY
import { axiom, implies } from "@purecore/one-proof-4-all";

axiom("New SHA-256 Cryptography", () => {
  implies(hash("123")).matches(/^[a-f0-9]{64}$/);
});

Single npm test command runs both. Same report. Same coverage. No rewrite needed.

πŸ“Š Why Adopt in Your Team?

πŸ’° Communication ROI

Problem Solution with one-proof-4-all
PMs can't read tests Narrative dialect produces readable specifications
Meetings to validate rules Tests become approvable documentation
Ambiguity between product and engineering Common language eliminates rework

Result: Fewer meetings, shorter validation cycles, fewer bugs reaching production.

⚑ Team Efficiency

Situation Benefit
Onboarding data scientists Learn only MathDialect, not entire ecosystem
Backend devs focused Use only ImperativeDialect for contracts
Domain specialization Each member produces more, faster

Result: Training in days, not weeks. Immediate contribution.

πŸ›‘οΈ Code Health (Zero Risk)

Fear Reality
"I'll have to rewrite 5,000 tests" ❌ False. Jest runs natively
"Another dependency to maintain" Incremental integration, not big-bang
"What if it fails mid-project?" Adopt in 1 new file. Evaluate. Expand if liked

Result: Immediate improvement without technical debt. Trivial rollback if needed.

πŸƒ Running Tests

# Run all specs
npx one-proof-4-all

# Watch mode
npx one-proof-4-all --watch

# Specific file
npx one-proof-4-all src/**/*.spec.ts

# With coverage
npx one-proof-4-all --coverage

πŸ“¦ Package Structure

@purecore/one-proof-4-all/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts          # Main entry point
β”‚   └── cli.ts            # CLI runner
β”œβ”€β”€ docs/                 # Documentation
β”œβ”€β”€ examples/             # Example specifications
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ api-test-dialect/ # API testing package
β”‚   └── reqify/          # HTTP utilities
└── types/
    └── api-types.ts     # TypeScript definitions

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

Cogfulness Ethical License (CEL) v1.0

πŸ™ Acknowledgments

  • Inspired by the need for domain-specific testing languages
  • Built with ❀️ for diverse development teams
  • Special thanks to all contributors and early adopters

Made with ❀️ by suissAI

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors