svelte-testing-library-meetup Svelte Themes

Svelte Testing Library Meetup

Examples shown during the first AMS sveltejs meetup

svelte-testing-library-meetup

To run it:

cd svelte-testing-library-meetup
npm install
npm run dev

For testing:

npm run test
npm run test:watch
npm run test:coverage

Setup

npm install @testing-library/svelte

npm install --save-dev jest

npm install --save-dev @testing-library/jest-dom

npm install svelte-jest

We add this scripts to the package.json

    {
        "scripts": {
            "test": "jest src",
            "test:watch": "npm run test -- --watch",
            "test:coverage": "npm run test -- --coverage"
        }
    }

We add the next script to the jest.config.js

module.exports = {
  transform: {
    "^.+\\.js$": "babel-jest",
    "^.+\\.svelte$": "svelte-jest"
  },
  moduleFileExtensions: ["js", "json", "svelte"],
  coverageReporters: ["html"],
  bail: false,
  verbose: false,
  setupFilesAfterEnv: ["@testing-library/jest-dom/extend-expect"]
};

To run babel

npm install babel-jest

npm install @babel/preset-env

And we add in the .babelrc file

    {
        "presets": [
            [
                "@babel/preset-env",
                {
                    "targets": {
                        "node": "current"
                    }
                }
            ]
        ]
    }

Top categories

Loading Svelte Themes