QUnit Tutorial
QUnit Useful Resources
Selected Reading
- QUnit - Nested Modules
- QUnit - Callbacks
- QUnit - Expect Assertions
- QUnit - Async Call
- QUnit - Only Test
- QUnit - Skip Test
- QUnit - Execution Procedure
- QUnit - Using Assertions
- QUnit - API
- QUnit - Basic Usage
- QUnit - Environment Setup
- QUnit - Overview
- QUnit - Home
QUnit Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
QUnit - Expect Assertions
QUnit - Expect Assertions
我们可以使用assert.expect()功能,检查在试验中所作陈述的数量。 在以下例子中,我们期望在试验中提出三项主张。
<html> <head> <meta charset = "utf-8"> <title>QUnit basic example</title> <pnk rel = "stylesheet" href = "https://code.jquery.com/qunit/qunit-1.22.0.css"> <script src = "https://code.jquery.com/qunit/qunit-1.22.0.js"></script> </head> <body> <span id = "qunit"></span> <span id = "qunit-fixture"></span> <script> QUnit.test( "multiple call test()", function( assert ) { assert.expect( 3 ); var done = assert.async( 3 ); setTimeout(function() { assert.ok( true, "first callback." ); done(); }, 500 ); setTimeout(function() { assert.ok( true, "second callback." ); done(); }, 500 ); setTimeout(function() { assert.ok( true, "third callback." ); done(); }, 500 ); }); </script> </body> </html>
Verify the Output
你应当看到以下结果:
Advertisements