Skip to content

Commit

Permalink
Merge branch 'main' into fix/missing-context-in-types
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick authored Oct 13, 2023
2 parents 3379545 + 66c9f45 commit 4cd7a7e
Show file tree
Hide file tree
Showing 28 changed files with 190 additions and 147 deletions.
4 changes: 2 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@
]
},
{
"login": "ysaskia",
"login": "ysitbon",
"name": "Yoann",
"avatar_url": "https://avatars.githubusercontent.com/u/1370679?v=4",
"profile": "https://github.com/ysaskia",
"profile": "https://github.com/ysitbon",
"contributions": [
"code"
]
Expand Down
6 changes: 0 additions & 6 deletions .babelrc

This file was deleted.

24 changes: 7 additions & 17 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,19 @@ module.exports = {
env: {
browser: true,
es6: true,
jest: true
'vitest-globals/env': true
},
parser: 'babel-eslint',
extends: [
'standard'
],
plugins: [
'svelte3',
'simple-import-sort'
],
extends: ['standard', 'plugin:vitest-globals/recommended'],
plugins: ['svelte', 'simple-import-sort'],
rules: {
'max-len': ['warn', { code: 100 }],
'simple-import-sort/imports': 'error',
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 2, maxEOF: 0 }]
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 2, maxEOF: 0 }],
},
overrides: [
{
files: ['**/*.svelte'],
processor: 'svelte3/svelte3'
}
],
parserOptions: {
ecmaVersion: 2019,
sourceType: 'module'
}
ecmaVersion: 2022,
sourceType: 'module',
},
}
25 changes: 25 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: husky
versions:
- 5.0.9
- 5.1.0
- 5.1.1
- 5.1.2
- 5.1.3
- 5.2.0
- dependency-name: "@commitlint/config-conventional"
versions:
- 12.0.0
- 12.0.1
- dependency-name: "@commitlint/cli"
versions:
- 12.0.0
- 12.0.1
8 changes: 2 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
if: ${{ !contains(github.head_ref, 'all-contributors') }}
strategy:
matrix:
node: [10, 12, 14, 16]
node: [16, 18, 20]
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
Expand All @@ -41,8 +41,7 @@ jobs:
release:
needs: main
runs-on: ubuntu-latest
if:
${{ github.repository == 'testing-library/svelte-testing-library' &&
if: ${{ github.repository == 'testing-library/svelte-testing-library' &&
contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha',
github.ref) && github.event_name == 'push' }}
steps:
Expand All @@ -59,9 +58,6 @@ jobs:
with:
useLockFile: false

- name: 🏗 Run build script
run: npm run build

- name: 🚀 Release
uses: cycjimmy/semantic-release-action@v2
with:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
/>
</a>

<p>Simple and complete Svelte testing utilities that encourage good testing
practices.</p>
<p>Simple and complete Svelte testing utilities that encourage good testing practices.</p>

[**Read The Docs**](https://testing-library.com/docs/svelte-testing-library/intro) |
[Edit the docs](https://github.com/alexkrolick/testing-library-docs)
Expand Down
1 change: 0 additions & 1 deletion dont-clean-up-after-each.js

This file was deleted.

90 changes: 34 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
"name": "@testing-library/svelte",
"version": "0.0.0-semantically-released",
"description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
"main": "dist/index.js",
"exports": {
".": {
"types": "./types/index.d.ts",
"default": "./src/index.js"
}
},
"type": "module",
"types": "types/index.d.ts",
"license": "MIT",
"homepage": "https://github.com/testing-library/svelte-testing-library#readme",
Expand All @@ -29,57 +35,50 @@
"e2e"
],
"files": [
"dist",
"dont-cleanup-after-each.js",
"pure.js",
"src/",
"types/index.d.ts"
],
"scripts": {
"toc": "doctoc README.md",
"lint": "eslint src --fix",
"clean": "rimraf dist",
"build": "npm run clean && babel src --out-dir dist --ignore '**/__tests__/**'",
"test": "jest src",
"test": "vitest run src",
"test:watch": "npm run test -- --watch",
"test:update": "npm run test -- --updateSnapshot --coverage",
"setup": "npm install && npm run validate",
"validate": "npm run clean && npm-run-all lint test build",
"validate": "npm-run-all lint test",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate"
},
"peerDependencies": {
"svelte": "3.x"
"svelte": "^3 || ^4"
},
"dependencies": {
"@testing-library/dom": "^8.1.0"
"@testing-library/dom": "^9.3.1"
},
"devDependencies": {
"@babel/cli": "^7.6.2",
"@babel/core": "^7.6.2",
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
"@babel/preset-env": "^7.6.2",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@testing-library/jest-dom": "^5.0.2",
"@types/jest": "^27.0.0",
"all-contributors-cli": "^6.9.0",
"babel-eslint": "^10.0.3",
"babel-jest": "^27.0.6",
"doctoc": "^2.0.0",
"eslint": "^7.2.0",
"eslint-config-standard": "^16.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-svelte3": "^3.0.0",
"husky": "^7.0.1",
"jest": "^27.0.0",
"lint-staged": "^11.1.1",
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@sveltejs/vite-plugin-svelte": "^2.4.2",
"@testing-library/jest-dom": "^5.16.5",
"@vitest/coverage-c8": "^0.33.0",
"all-contributors-cli": "^6.26.0",
"doctoc": "^2.2.1",
"eslint": "^8.43.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-svelte": "^2.32.0",
"eslint-plugin-vitest-globals": "^1.3.1",
"husky": "^8.0.3",
"jsdom": "^22.1.0",
"lint-staged": "^13.2.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.1",
"svelte": "^3.0.0",
"svelte-jester": "^2.1.4"
"prettier": "^3.0.0",
"svelte": "^4.0.1",
"vite": "^4.3.9",
"vitest": "^0.33.0"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -107,26 +106,5 @@
"extends": [
"@commitlint/config-conventional"
]
},
"jest": {
"testPathIgnorePatterns": [
"src/__tests__/fixtures"
],
"collectCoverageFrom": [
"src/*.js"
],
"setupFilesAfterEnv": [
"@testing-library/jest-dom/extend-expect"
],
"testEnvironment": "jsdom",
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.svelte$": "svelte-jester",
"^.+\\.html$": "svelte-jester"
},
"moduleFileExtensions": [
"js",
"svelte"
]
}
}
2 changes: 0 additions & 2 deletions pure.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/auto-cleanup-skip.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`auto-cleanup-skip second 1`] = `"<div><h1 data-testid=\\"test\\">Hello world!</h1> <div>we have undefined</div> <button>Button</button></div>"`;
exports[`auto-cleanup-skip > second 1`] = `""`;
5 changes: 3 additions & 2 deletions src/__tests__/__snapshots__/render.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`render should accept svelte component options 1`] = `
exports[`render > should accept svelte component options 1`] = `
<body>
<div>
<h1
Expand All @@ -18,6 +18,7 @@ exports[`render should accept svelte component options 1`] = `
<button>
Button
</button>
<!--&lt;Comp&gt;-->
<div />
</div>
</body>
Expand Down
11 changes: 7 additions & 4 deletions src/__tests__/act.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { beforeEach, describe, expect, test } from 'vitest'

import { act, fireEvent, render as stlRender } from '..'
import Comp from './fixtures/Comp'
import Comp from './fixtures/Comp.svelte'

describe('act', () => {
let props
Expand Down Expand Up @@ -36,9 +38,10 @@ describe('act', () => {
})

test('accepts async functions', async () => {
const sleep = (ms) => new Promise(resolve => {
setTimeout(() => resolve(), ms)
})
const sleep = (ms) =>
new Promise((resolve) => {
setTimeout(() => resolve(), ms)
})

const { getByText } = render()
const button = getByText('Button')
Expand Down
8 changes: 5 additions & 3 deletions src/__tests__/auto-cleanup-skip.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Comp from './fixtures/Comp'
import { beforeAll, describe, expect, test } from 'vitest'

import Comp from './fixtures/Comp.svelte'

describe('auto-cleanup-skip', () => {
let render

beforeAll(() => {
beforeAll(async () => {
process.env.STL_SKIP_AUTO_CLEANUP = 'true'
const stl = require('..')
const stl = await import('..')
render = stl.render
})

Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/auto-cleanup.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { describe, expect, test } from 'vitest'

import { render } from '..'
import Comp from './fixtures/Comp'
import Comp from './fixtures/Comp.svelte'

describe('auto-cleanup', () => {
// This just verifies that by importing STL in an
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/debug.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { prettyDOM } from '@testing-library/dom'
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'

import { render } from '..'
import Comp from './fixtures/Comp'
import Comp from './fixtures/Comp.svelte'

describe('debug', () => {
beforeEach(() => {
jest.spyOn(console, 'log').mockImplementation(() => {})
vi.spyOn(console, 'log').mockImplementation(() => { })
})

afterEach(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/events.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { describe, expect, test } from 'vitest'

import { fireEvent, render } from '..'
import Comp from './fixtures/Comp'
import Comp from './fixtures/Comp.svelte'

describe('events', () => {
test('state changes are flushed after firing an event', async () => {
Expand Down
6 changes: 4 additions & 2 deletions src/__tests__/fixtures/Comp.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<svelte:options accessors />

<script>
import { getContext } from 'svelte'
Expand All @@ -12,10 +14,10 @@
}
</script>

<style></style>

<h1 data-testid="test">Hello {name}!</h1>

<div>we have {contextName}</div>

<button on:click={handleClick}>{buttonText}</button>

<style></style>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script>
export let name
let buttonText = "Button Text"
let buttonText = 'Button Text'
function handleClick() {
buttonText = "Button Clicked"
function handleClick () {
buttonText = 'Button Clicked'
}
</script>

Expand Down
Loading

0 comments on commit 4cd7a7e

Please sign in to comment.