Skip to content
Examples shown during the first AMS sveltejs meetup
HTML JavaScript CSS
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
coverage
public initial commit Nov 15, 2019
src initial commit Nov 15, 2019
.babelrc initial commit Nov 15, 2019
.gitignore
README.md initial commit Nov 15, 2019
jest.config.js
package-lock.json
package.json initial commit Nov 15, 2019
rollup.config.js initial commit Nov 15, 2019
rollup_start_dev.js initial commit Nov 15, 2019

README.md

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"
                    }
                }
            ]
        ]
    }
You can’t perform that action at this time.