QUnit คืออะไร

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: QUnit คืออะไร

QUnit คืออะไร

โดย Ik Kat » 29/06/2017 2:59 pm

QUnit เป็นเครื่องมือในการกำหนดค่าสถานะ , การทดสอบ , การแสดงผล ที่พัฒนาขึ้นด้วย JavaScript ซึ่งรองรับทั้ง jQuery,
jQuery UI และ jQuery Mobile
MT19 29-6-60(31).png
MT19 29-6-60(31).png (6.57 KiB) Viewed 1075 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 1075 times
สามารถดาวน์โหลดได้ที่ : http://qunitjs.com/

ข้างบน