Pedagogical test
A pedagogical test is defined as a system of tasks of a certain content, of increasing difficulty, of a specific form, which allows one to qualitatively and effectively measure the level and evaluate the structure of students’ preparedness. In the pedagogical test, tasks are arranged in order of increasing difficulty - from the easiest to the most difficult.
Integrative test
An integrative test can be called a test consisting of a system of tasks that meet the requirements of integrative content, a test form, and increasing difficulty of tasks aimed at a generalized final diagnosis of the preparedness of a graduate of an educational institution.
Diagnostics is carried out by presenting such tasks, the correct answers to which require integrated (generalized, clearly interrelated) knowledge in the field of two or more academic disciplines. The creation of such tests is given only to those teachers who have knowledge of a number of academic disciplines and understand important role interdisciplinary connections in learning, are able to create tasks, the correct answers to which require students to have knowledge of various disciplines and the ability to apply such knowledge. Integrative testing is preceded by the organization of integrative training. Unfortunately, the current class-lesson form of conducting classes, combined with excessive fragmentation of academic disciplines, together with the tradition of teaching individual disciplines (rather than generalized courses), will for a long time hinder the implementation of an integrative approach in the processes of learning and monitoring preparedness.
The advantage of integrative tests over heterogeneous ones lies in the greater informative content of each task and in the smaller number of tasks themselves.
The methodology for creating integrative tests is similar to the methodology for creating traditional tests, with the exception of the work of determining the content of tasks. To select the content of integrative tests, the use of expert methods is mandatory.
Adaptive test
The adaptive test works like a good examiner. First, he "asks" a question of moderate difficulty, and the resulting answer is immediately evaluated. If the answer is correct, then the assessment of the test taker’s capabilities increases. In this case, a more difficult question is asked. If the student answers a question successfully, the next one is chosen to be more difficult; if unsuccessful, the next one is chosen easier.
The main advantage of an adaptive test over a traditional one is efficiency. An adaptive test can determine the test taker's knowledge level with fewer questions (sometimes the test length is reduced by up to 60%).
In an adaptive test, on average, you have more time to think about each question than in a regular test. For example, instead of taking 2 minutes per question, an adaptive test taker might end up with 3 or 4 minutes (depending on how many questions they need to answer).
The reliability of the results of the adaptive test coincides with the reliability of fixed-length tests. Both types of tests equally accurately assess the level of knowledge.
However, it is widely believed that the adaptive test is a more accurate assessment of knowledge. This is not true.
Total applications. But between these two stages of testing, others occur. I, like many others, call such tests integration.
A few words about terminology
Having talked a lot with test-driven development enthusiasts, I came to the conclusion that they have a different definition for the term “integration tests.” From their point of view, an integration test tests the "external" code, that is, the one that interacts with the "outside world", the world of the application.
So if their code uses Ajax or localStorage or IndexedDB and therefore cannot be tested with unit tests, they wrap that functionality in an interface and mock that interface for unit tests, and testing the actual implementation of the interface is called an "integration test" " From this point of view, an "integration test" simply tests code that interacts with the "real world" outside of those units that operate without regard to the real world.
I, like many others, tend to use the term "integration tests" to refer to tests that test the integration of two or more units (modules, classes, etc.). It doesn't matter if you hide real world through locked interfaces.
My rule of thumb on whether to use real implementations Ajax and other I/O (input/output) operations in integration tests is this: if you can do it and the tests still run quickly and don't behave strangely, then test the I/O. If the I/O operation is complex, slow, or just weird, then use mock objects in your integration tests.
In our calculator, fortunately, the only real I/O is the DOM. There are no Ajax calls or other reasons to write mocks.
Fake DOM
The question arises: is it necessary to write a fake DOM in integration tests? Let's apply my rule. Will using real DOM make tests slow? Unfortunately, the answer is yes: using the real DOM means using the real browser, which makes tests slow and unpredictable.
Do we separate most of the code from the DOM or test everything together in E2E tests? Both options are not optimal. Luckily, there is a third solution: jsdom. This wonderful and amazing package does exactly what you expect from it - implements the DOM in NodeJS.
It works, it's fast, it runs in Node. If you use this tool, you can stop treating the DOM as "I/O". And this is very important, because separating the DOM from the front-end code is difficult, if not impossible. (For example, I don't know how to do this.) I'm guessing that jsdom was written specifically for running frontend tests under Node.
Let's see how it works. As usual, there is initialization code and there is test code, but this time we will start with the test code. But before that, a retreat.
Retreat
This part is the only part of the series that is focused on a specific framework. And the framework I chose is React. Not because it's the best framework. I firmly believe that there is no such thing. I don't even think there are better frameworks for specific use cases. The only thing I believe in is that people should use the environment in which they are most comfortable working.
And the framework I'm most comfortable working with is React, so the following code is written in it. But as we will see, frontend integration tests using jsdom should work in all modern frameworks.
Let's go back to using jsdom.
Using jsdom
const React = require("react") const e = React.createElement const ReactDom = require("react-dom") const CalculatorApp = require("../../lib/calculator-app") ... describe( "calculator app component", function () ( ... it("should work", function () ( ReactDom.render(e(CalculatorApp), document.getElementById("container")) const displayElement = document.querySelector(" .display") expect(displayElement.textContent).to.equal("0")The interesting ones are lines 10 through 14. On line 10 we render the CalculatorApp component, which (if you've been following the code in the repository) also renders the Display and Keypad components.
We then check that in lines 12 and 14 the element in the DOM shows an initial value of 0 on the calculator display.
And this code, which runs under Node, uses document ! The document global variable is a browser variable, but it's here in NodeJS. To make these lines work, a very large amount of code is required. This very large amount of code that resides in jsdom is essentially a complete implementation of everything in the browser, minus the rendering itself!
Line 10, which calls ReactDom to render the component, also uses document (and window), since ReactDom uses them frequently in its code.
So who creates these global variables? Test - let's look at the code:
Before(function () ( global.document = jsdom(`