npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jstormes/apicize-tools

v1.1.0

Published

CLI tools for working with .apicize API test files - convert between .apicize and TypeScript/Mocha/Chai tests

Readme

@jstormes/apicize-tools

npm version License: MIT Node.js Version npm downloads

CLI tools for working with .apicize API test files - seamlessly convert between .apicize format and executable TypeScript/Mocha/Chai tests.

🚀 Quick Start

Installation

# Install globally via npm
npm install -g @jstormes/apicize-tools

# Or use with npx without installation
npx @jstormes/apicize-tools export myfile.apicize

Basic Usage

# Export .apicize to TypeScript tests
apicize export demo.apicize --output ./tests

# Import TypeScript tests back to .apicize
apicize import ./tests/demo --output demo-updated.apicize

# Validate .apicize file structure
apicize validate demo.apicize

# Create new .apicize file from template
apicize create new-api-test --template rest-crud

# Run tests directly
apicize run demo.apicize --scenario production

📖 Features

  • Bidirectional Conversion: Export .apicize files to TypeScript and import back with 100% data fidelity
  • Test Execution: Run API tests directly from .apicize files
  • Multiple Scenarios: Support for different test environments (dev, staging, production)
  • Data-Driven Testing: CSV and JSON data file support for bulk testing
  • Authentication: Built-in support for Basic, OAuth2, API Key authentication
  • TypeScript Support: Fully typed with TypeScript declarations
  • CI/CD Ready: Easy integration with CI/CD pipelines
  • Large File Support: Efficiently handle files with 1000+ requests

🛠️ Commands

export - Convert .apicize to TypeScript

apicize export <file.apicize> [options]

Options:
  -o, --output <dir>     Output directory (default: "./tests")
  -s, --scenario <name>  Use specific scenario
  --split                Split into multiple files
  --force                Overwrite existing files

import - Convert TypeScript to .apicize

apicize import <test-folder> [options]

Options:
  -o, --output <file>    Output .apicize file
  --merge                Merge with existing file

validate - Validate .apicize Files

apicize validate <files...> [options]

Options:
  --strict               Enable strict validation
  --fix                  Auto-fix common issues

create - Generate New .apicize Files

apicize create <name> [options]

Options:
  -t, --template <type>  Use template (rest-crud, graphql, websocket)
  --interactive          Interactive mode

run - Execute Tests

apicize run <file.apicize> [options]

Options:
  -s, --scenario <name>  Use specific scenario
  --reporter <type>      Test reporter (spec, json, tap)
  --timeout <ms>         Request timeout

📁 Generated Test Structure

When you export a .apicize file, the tool generates a complete TypeScript test project:

tests/
├── [workbook-name]/
│   ├── index.spec.ts         # Main test suite
│   ├── suites/              # Test groups
│   │   ├── auth.spec.ts
│   │   └── crud.spec.ts
│   └── metadata/            # Preserved metadata for reimport
│       └── workbook.json
├── package.json             # Dependencies
├── tsconfig.json           # TypeScript config
└── .mocharc.json          # Mocha configuration

🔧 Configuration

Create an apicize.config.json file in your project root:

{
  "export": {
    "splitByGroup": true,
    "includeMetadata": true,
    "generateHelpers": true
  },
  "import": {
    "preserveComments": true,
    "validateOnImport": true
  },
  "defaults": {
    "timeout": 30000,
    "scenario": "development"
  }
}

🤝 Integration

CI/CD Pipeline

# GitHub Actions example
- name: Install Apicize Tools
  run: npm install -g @jstormes/apicize-tools

- name: Validate API tests
  run: apicize validate **/*.apicize

- name: Run API tests
  run: apicize run tests/*.apicize --scenario production --reporter json

Package.json Scripts

{
  "scripts": {
    "test:api": "apicize run tests/*.apicize",
    "test:validate": "apicize validate **/*.apicize",
    "test:export": "apicize export tests/*.apicize --output ./generated"
  }
}

📚 Documentation

🧪 Testing

The generated TypeScript tests use Mocha and Chai:

describe('API Tests', () => {
    it('should return successful response', () => {
        expect(response.status).to.equal(200);

        const JSON_body = (response.body.type === BodyType.JSON)
            ? response.body.data
            : expect.fail('Response not JSON');

        expect(JSON_body.id).to.exist;
        output('savedId', JSON_body.id); // Pass to next test
    });
});

🔑 Authentication

Configure authentication in your .apicize files:

{
  "authorizations": [{
    "id": "api-auth",
    "type": "OAuth2Client",
    "accessTokenUrl": "{{authUrl}}/token",
    "clientId": "{{clientId}}",
    "clientSecret": "{{clientSecret}}"
  }]
}

📊 Performance

  • Handles 1000+ request files efficiently
  • Validation: ~20 requests/second
  • Export: ~10 requests/second
  • Round-trip accuracy: >95%
  • Memory efficient with streaming support

🐛 Troubleshooting

Common Issues

  1. Command not found: Ensure global installation with npm install -g @jstormes/apicize-tools
  2. TypeScript errors: Check Node.js version (>=16.0.0 required)
  3. Import failures: Ensure metadata comments are preserved in TypeScript files

For more help, see our Troubleshooting Guide.

📄 License

MIT © Apicize Tools

🤝 Contributing

Contributions are welcome! Please read our Contributing Guide for details.

🔗 Links


Built with ❤️ by the Apicize Team