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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@codepunter-labs/mock-cloudinary

v0.2.0

Published

TODO

Readme

@codepunter-labs/mock-cloudinary

Mock SDK for Cloudinary Node.js SDK. Provides fully-typed mock implementations for testing Cloudinary image and video upload, transformation, and management without making real API calls.

npm version GitHub

Installation

npm install @codepunter-labs/mock-cloudinary

Features

  • Upload: Upload files with options
  • Admin: List resources, get resource details, delete, rename
  • URL Generation: Generate transformation URLs
  • Type-safe: Full TypeScript support with accurate API types
  • Test Framework Agnostic: Works with Jest, Vitest, and other spy-based frameworks

Repository

  • GitHub: https://github.com/DERRICK-TORKORNOO/mock-sdks/tree/main/packages/mock-cloudinary
  • Source Code: src/
  • Tests: tests/

Usage

Basic Setup

import { vi } from 'vitest';
import { createMockCloudinary } from '@codepunter-labs/mock-cloudinary';

const cloudinary = createMockCloudinary({ spy: vi.fn });

Using with Jest

import { createMockCloudinary } from '@codepunter-labs/mock-cloudinary';

const cloudinary = createMockCloudinary({ spy: jest.fn });

Example: Upload Image

// Default behavior - returns realistic mock data
const result = await cloudinary.upload('image.jpg', {
  public_id: 'my_image',
  resource_type: 'image'
});

Example: List Resources

const result = await cloudinary.listResources({
  resource_type: 'image',
  max_results: 10
});

Example: Generate URL

const url = cloudinary.url('my_image', {
  width: 300,
  height: 200,
  crop: 'fill'
});

Example: Override Mock Response

import { makeUploadResponse } from '@codepunter-labs/mock-cloudinary';

cloudinary.upload.mockResolvedValue(
  makeUploadResponse({ public_id: 'custom_image', width: 1920 })
);

Example: Error Simulation

import { MockErrors } from '@codepunter-labs/mock-core';

cloudinary.upload.mockRejectedValue(
  MockErrors.badRequest('Invalid file format')
);

API Reference

MockCloudinary

  • upload(file, options?) - Upload file
  • listResources(options?) - List resources
  • getResource(publicId) - Get resource details
  • destroy(publicId) - Delete resource
  • rename(from, to, options?) - Rename resource
  • url(publicId, options?) - Generate transformation URL

Fixture Factories

  • makeUploadResponse(options?) - Create upload response
  • makeResource(options?) - Create resource
  • makeDeleteResponse(options?) - Create delete response
  • makeRenameResponse(options?) - Create rename response

Testing Patterns

Test Success Path

test('should upload image successfully', async () => {
  const cloudinary = createMockCloudinary({ spy: vi.fn });
  
  const result = await cloudinary.upload('image.jpg');
  
  expect(result.public_id).toBeDefined();
  expect(result.secure_url).toContain('cloudinary.com');
});

Test Error Handling

test('should handle invalid file format error', async () => {
  const cloudinary = createMockCloudinary({ spy: vi.fn });
  
  cloudinary.upload.mockRejectedValue(
    CloudinaryErrors.invalidFileFormat()
  );
  
  await expect(cloudinary.upload('invalid.xyz')).rejects.toMatchObject({ message: /Invalid file format/ });
});

Test with Custom Data

test('should use custom public ID', async () => {
  const cloudinary = createMockCloudinary({ spy: vi.fn });
  
  cloudinary.upload.mockResolvedValue(
    makeUploadResponse({ public_id: 'custom_image' })
  );
  
  const result = await cloudinary.upload('image.jpg');
  expect(result.public_id).toBe('custom_image');
});

License

MIT