preactjs-templates / default

The default template for Preact CLI
https://github.com/developit/preact-cli
MIT License
78 stars 70 forks source link

Npm run test fails #30

Open laszlocph opened 5 years ago

laszlocph commented 5 years ago

https://github.com/preactjs/preact-cli/issues/892

thesobercoder commented 4 years ago

I'm also getting the same error -

image

thesobercoder commented 4 years ago

I was able to fix this by doing the following changes. I've also fixed the lint issue. The default lint script doesn't work. -

jest.config.js

module.exports = {
    preset: "jest-preset-preact",
    setupFiles: [
        "<rootDir>/src/tests/__mocks__/setupTests.js",
        "<rootDir>/src/tests/__mocks__/browserMocks.js",
        "<rootDir>/src/tests/__mocks__/fileMocks.js"
    ],
    testURL: "http://localhost:8080",
    moduleNameMapper: {
        "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
            "<rootDir>/src/tests/__mocks__/fileMocks.js"
    },
    testPathIgnorePatterns: ["<rootDir>/node_modules/"],
    testMatch: ["<rootDir>/src/tests/**/*.test.{js,jsx,ts,tsx}"],
    transform: {
        "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest"
    }
};

package.json

"scripts": {
        "lint": "eslint ./src --ext .js --ext .ts --ext .jsx --ext .tsx",
        "test": "jest"
    },
ForsakenHarmony commented 4 years ago

Has this not been fixed with #31 ?