Skip to content

pubkey/microsoft-onedrive-mock

Repository files navigation

microsoft-onedrive-mock


Mock-Server that simulates being Microsoft OneDrive (Graph API).
Used for testing the RxDB OneDrive-Sync.
Sister project to google-drive-mock.
Mostly Vibe-Coded.

Installation

npm install microsoft-onedrive-mock

Usage

import { startServer } from 'microsoft-onedrive-mock';

// start the server
const port = 3000;
const server = startServer(port);

// Read the drive root
const readResponse = await fetch(`http://localhost:3000/v1.0/me/drive/root`, {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer valid-token'
    }
});
const folderContent = await readResponse.json();
console.log('Read Root:', folderContent);

// Stop the server
server.close();

Tech

  • TypeScript
  • Express
  • Vitest

Browser Testing

To run tests inside a headless browser (Chromium):

npm run test:browser

Real Microsoft Graph API Testing

To run tests against the real Microsoft Graph / OneDrive API instead of the mock:

  1. Create a .ENV file (see .ENV_EXAMPLE):
    TEST_TARGET=real
    ONEDRIVE_TOKEN=your-access-token
    
  2. You can generate a valid ONEDRIVE_TOKEN quickly by running the included login script and following the browser prompts:
    npm run example:login
  3. Run tests:
    npm run test:real

Contributing

GitHub issues for this project are closed. If you find a bug, please create a Pull Request with a test case reproducing the issue.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors