google-drive-mock
v1.1.4
Published
Mock-Server that simulates being google-drive. Used for testing.
Maintainers
Readme
google-drive-mock

Installation
npm install google-drive-mockUsage
import { startServer } from 'google-drive-mock';
// start the server
const port = 3000;
const server = startServer(port);
// Store a file
const createResponse = await fetch('http://localhost:3000/drive/v3/files', {
method: 'POST',
headers: {
'Authorization': 'Bearer valid-token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'test-file.txt',
mimeType: 'text/plain'
})
});
const file = await createResponse.json();
console.log('Created File:', file);
// Read the file
const readResponse = await fetch(`http://localhost:3000/drive/v3/files/${file.id}`, {
method: 'GET',
headers: {
'Authorization': 'Bearer valid-token'
}
});
const fileContent = await readResponse.json();
console.log('Read File:', fileContent);
// Stop the server
server.close();
Tech
- TypeScript
- Express
- Vitest
Browser Testing
To run tests inside a headless browser (Chromium):
npm run test:browserReal Google Drive API Testing
To run tests against the real Google Drive API instead of the mock:
- Create a
.ENVfile (see.ENV_EXAMPLE):TEST_TARGET=real GDRIVE_TOKEN=your-access-token - Run tests:
npm 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.
