Skip to main content
Glama
crawler.service.spa.test.ts1.66 kB
import { SPAMock } from '../../services/crawler/test-utils/mocks/SPAMock'; import axios from 'axios'; // Initialize the SPA mock with desired options const spaMock = new SPAMock({ baseUrl: 'https://spa-test.example.com', framework: 'react', responseDelay: 100, verbose: true }); // Add routes to the SPA mock spaMock.addRoutes([ { path: '/about', title: 'About Us', content: '<h1>About Us</h1>' }, { path: '/contact', title: 'Contact', content: '<h1>Contact</h1>' }, { path: '/products/:id', title: 'Product Detail', content: '<h1>Product Detail</h1>' } ]); // Start the mock server spaMock.start(); describe('Crawler Service SPA Tests', () => { afterAll(() => { // Stop the mock server after tests spaMock.stop(); }); it('should fetch the home page', async () => { const response = await axios.get('https://spa-test.example.com/'); expect(response.status).toBe(200); expect(response.data).toContain('Home Page'); }); it('should fetch the about page', async () => { const response = await axios.get('https://spa-test.example.com/about'); expect(response.status).toBe(200); expect(response.data).toContain('About Us'); }); it('should fetch the contact page', async () => { const response = await axios.get('https://spa-test.example.com/contact'); expect(response.status).toBe(200); expect(response.data).toContain('Contact'); }); it('should handle dynamic product routes', async () => { const response = await axios.get('https://spa-test.example.com/products/123'); expect(response.status).toBe(200); expect(response.data).toContain('Product Detail'); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/visheshd/docmcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server