0Pricing
Edge Computing with Cloudflare Workers & Deno · Lección

Probar aplicaciones Deno

Escriba y ejecute pruebas para aplicaciones Deno mediante el ejecutor de pruebas integrado, aserciones y mocking para crear código edge fiable.

Probar aplicaciones Deno es una lección gratuita de Edge Computing with Cloudflare Workers & Deno en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Edge Computing with Cloudflare Workers & Deno, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Edge Computing with Cloudflare Workers & Deno incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

Built-in Testing

Deno ships with a built-in test runner — no extra framework or config needed. Just write tests and run deno test.

Your First Test

Register a test with Deno.test. It takes a name and a function.

Deno.test('adds numbers', () => {
  const sum = 2 + 3;
  if (sum !== 5) throw new Error('wrong');
});

The Assertions Module

Use the standard library's assertions for clearer failures instead of manual throws.

import { assertEquals } from 'jsr:@std/assert';

Deno.test('math', () => {
  assertEquals(2 + 3, 5);
});

Running Tests

Run all tests in your project. Deno discovers files ending in _test.ts or .test.ts automatically.

deno test
deno test --allow-net

Async Tests

Tests can be async — just return a promise or mark the function async. Deno awaits it before reporting.

Deno.test('fetches data', async () => {
  const res = await fetch('https://example.com');
  assertEquals(res.status, 200);
});

Test Steps

Break a complex test into named steps with t.step for clearer output and partial results.

Deno.test('user flow', async (t) => {
  await t.step('signup', () => {});
  await t.step('login', () => {});
});

Permissions in Tests

Tests obey Deno's permission model. A test needing network access fails without --allow-net, so you test real security boundaries.

Mocking & Spies

The std testing module provides spies, stubs, and mocks to isolate units from external services.

import { spy } from 'jsr:@std/testing/mock';
const log = spy(console, 'log');

Snapshot Testing

Deno's assertSnapshot stores expected output and compares future runs against it — great for stable structured responses.

Coverage Reports

Measure how much code your tests exercise with the built-in coverage tools.

deno test --coverage=cov
deno coverage cov

Testing Edge Logic

Structure handlers as pure functions of a Request so you can test them without a running server — ideal for edge code.

export function handler(req: Request) {
  return new Response('ok');
}

Quick Check

Test your Deno testing knowledge.

Recap

You learned to write tests with Deno.test, use std assertions, handle async and steps, respect permissions, mock dependencies, and measure coverage — keeping your edge code reliable.

Preguntas frecuentes

¿La lección «Probar aplicaciones Deno» es gratis?

Sí — el texto completo de «Probar aplicaciones Deno» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Edge Computing with Cloudflare Workers & Deno, actualiza a CoddyKit PRO. El curso de Edge Computing with Cloudflare Workers & Deno incluye 4 lecciones en total.

¿Qué aprenderé en «Probar aplicaciones Deno»?

Escriba y ejecute pruebas para aplicaciones Deno mediante el ejecutor de pruebas integrado, aserciones y mocking para crear código edge fiable. Practicas Edge Computing with Cloudflare Workers & Deno con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Edge Computing with Cloudflare Workers & Deno?

No se requiere experiencia previa. Edge Computing with Cloudflare Workers & Deno en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.

¿Cuánto tiempo toma la lección «Probar aplicaciones Deno»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Edge Computing with Cloudflare Workers & Deno?

Sí. Cada lección de Edge Computing with Cloudflare Workers & Deno incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Fundamentos del runtime de Deno
  2. Sistema de módulos y permisos
  3. Desarrollo de aplicaciones locales con Deno
  4. Probar aplicaciones Deno
← Volver a Edge Computing with Cloudflare Workers & Deno