Get started with jasmine CDN

MIT licensed

Jasmine is a popular JS testing framework that provides a behavior-driven development approach to writing and executing tests.

Tags:
  • bdd
  • testing

Stable version

Copied!

How to start using jasmine CDN


// Include Jasmine library from the CDN
const Jasmine = (() => {
  const script = document.createElement('script');
  script.src = 'https://cdn.cdnhub.io/jasmine/5.1.2/jasmine.min.js';
  document.head.appendChild(script);

  return new Promise((resolve) => {
    script.onload = () => {
      resolve(window.jasmine);
    };
  });
})();

// Your code to test
const add = (a, b) => a + b;

// Define your test spec
Jasmine.specs('Addition', () => {
  describe('add', () => {
    it('should correctly add two numbers', () => {
      expect(add(1, 2)).toEqual(3);
      expect(add(5, 3)).toEqual(8);
    });
  });
});

// Run the tests
Jasmine.execute();
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions