Estou realizando o curso implementando os mesmos comandos só que para outro exemplo mais obtive um erro alguém pode me ajudar:
meu index.js
const somaCalculadora = (a, b) => a + b;
const subCalculadora = (c, d) => c - d;
export {
somaCalculadora,
subCalculadora,
};
dentro de uma pasta test tenho arquivo calculadora.test.js
import { somaCalculadora, subCalculadora } from '../index.js';
describe('Deve retornar a soma entre dois numeros', () => {
const esperado = 30;
const retornado = somaCalculadora(10, 20);
expect(retornado).toBe(esperado);
});
meu package.json
{
"name": "aula1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
"test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch --coverage"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^8.24.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0"
},
"dependencies": {
"jest": "28.1.0",
"save-dev": "0.0.1-security"
},
"type":"module"
}
quando realizo o teste npm run test
> aula1@1.0.0 test
> node --experimental-vm-modules node_modules/jest/bin/jest.js
(node:2448) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
FAIL test/calculadora.test.js
● Test suite failed to run
Your test suite must contain at least one test.
at onResult (node_modules/@jest/core/build/TestScheduler.js:172:18)
at node_modules/@jest/core/build/TestScheduler.js:300:17
at node_modules/emittery/index.js:311:13
at Array.map (<anonymous>)
at Emittery.emit (node_modules/emittery/index.js:309:23)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.742 s
Ran all test suites.