TAILIEUCHUNG - Phát triển Javascript - part 38

Tham khảo tài liệu 'phát triển javascript - part 38', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | The Runtime 343 I named the project chapp as in chat app. The deps directory is for third party dependencies the other two should be self-explanatory. Testing Framework Node has a CommonJS compliant Assert module but in line with the low-level focus of Node it only provides a few assertions. No test runner no test cases and no high-level testing utilities just the bare knuckles assertions enabling framework authors to build their own. For this chapter we will be using a version of a small testing framework called Nodeunit. Nodeunit was originally designed to look like QUnit jQuery s unit testing framework. I have added some bells and whistles to it to bring it slightly closer to JsTestDriver in style so testing with it should look familiar. The version of Nodeunit used for this chapter can be downloaded from the book s website 3 and should live in deps nodeunit. Listing shows a small script to help run tests. Save it in . run-tests and make it executable with chmod x run_tests. Listing Script to run tests usr local bin node dirname dirname deps dirname lib require nodeunit . test chapp Starting Point There s a lot of code ahead of us and to get us started I will provide a basic starting point consisting of a small HTTP server and a convenient script to start it. We will then proceed top-down actually taking the server for a spin halfway. The Server To create an HTTP server in Node we need the http module and its create-Server method. This method accepts a function which will be attached as a request listener. CommonJS modules will be properly introduced in a moment 3. http Download from 344 Server-Side JavaScript with as will Node s event module. Listing shows the server which should live in lib chapp . Listing A HTTP server var http require http var url require url var crController .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.