QUnit คืออะไร

jQuery & Ajax Knowledge ความรู้เกี่ยวกับ Javascript , jQuery และ Ajax

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
Ik Kat
PHP Super Member
PHP Super Member
โพสต์: 291
ลงทะเบียนเมื่อ: 26/06/2017 2:32 pm

QUnit คืออะไร

โพสต์ที่ยังไม่ได้อ่าน โดย Ik Kat »

QUnit เป็นเครื่องมือในการกำหนดค่าสถานะ , การทดสอบ , การแสดงผล ที่พัฒนาขึ้นด้วย JavaScript ซึ่งรองรับทั้ง jQuery,
jQuery UI และ jQuery Mobile
MT19 29-6-60(31).png
MT19 29-6-60(31).png (6.57 KiB) Viewed 1040 times
A minimal QUnit test setup :

โค้ด: เลือกทั้งหมด

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>QUnit Example</title>
  <link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.3.3.css">
</head>
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
  <script src="https://code.jquery.com/qunit/qunit-2.3.3.js"></script>
  <script src="tests.js"></script>
</body>
</html>
The contents of tests.js :

โค้ด: เลือกทั้งหมด

QUnit.test( "hello test", function( assert ) {
  assert.ok( 1 == "1", "Passed!" );
});
Install QUnit globally so you can use the CLI :

โค้ด: เลือกทั้งหมด

$ npm install -g qunitjs
Create test files in a test directory and then simply run : And you should see some output like :

โค้ด: เลือกทั้งหมด

TAP version 13
ok 1 Module > Test #1
ok 2 Module > Test #2
1..2
# pass 2
# skip 0
# todo 0
# fail 0

โค้ด: เลือกทั้งหมด

$ qunit 'tests/*-test.js'

โค้ด: เลือกทั้งหมด

$ qunit --help
สนับสนุน Browsers เช่นเดียวกับ jQuery 3.x.
ประโยชน์ QUnit : สามารถทดสอบการทำงานได้หลายฟังก์ชั่นพร้อมกัน
MT19 29-6-60(32).png
MT19 29-6-60(32).png (17.64 KiB) Viewed 1040 times
สามารถดาวน์โหลดได้ที่ : http://qunitjs.com/

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 27