I want to use Import/export feature of ES6 modules (since my entire project uses that) with Jest 26.1.0.
I have created a directory for my test cases called testCases/ which contains a math.mjs file. Now I am trying to import this file in math.test.js (for Jest). Whenever I run npm run test, it throws the following error.
>Details:
    /home/jatin/Downloads/Node.js/task-manager-app/TestCases/math.test.js:1
    import calc from "../src/math.mjs";
    ^^^^^^
    SyntaxError: Cannot use import statement outside a module
      at Runtime._execModule (node_modules/jest-runtime/build/index.js:1179:56)
Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.556 s
Ran all test suites.
npm ERR! Test failed.  See above for more details.
I even tried changing Jest configuration,as per the documentation and other GitHub issues but no success so far.
Below is my math.mjs testing file
  const calc = (total, tippercent) => {
    const tip = total * tippercent;
    return total + tip;
}
export default calc
And this is my math.test.js
import calc from "../src/math.mjs";
test("to calculate tipercent", () => {});
How can we configure Jest to parse .mjs modules?
 
     
     
     
    