Skip to content

Cut back to minimal reproduction #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,50 @@

## Get started

This project is using nx

```sh
npm install
```

to run test:
## Failure

Run test:

```sh
npx nx test counter
npm test
```

Observe:

```
FAIL |@svelteunit/counter| src/lib/counter.spec.js > counter
Svelte error: rune_outside_svelte
The `$state` rune is only available inside `.svelte` and `.svelte.js/ts` files
❯ Module.rune_outside_svelte ../../node_modules/svelte/src/internal/client/errors.js:304:17
303| const error = new Error(`state_descriptors_fixed\nProperty descriptors defined on \`$state\` objects must contain \`value\` and always be \`enumerable\`, \`configurable\` and \`writable\`.`);
304|
305| error.name = 'Svelte error';
| ^
306| throw error;
307| } else {
❯ get ../../node_modules/svelte/src/internal/client/runtime.js:1197:28
❯ mount ../../node_modules/@testing-library/svelte/src/core/modern.svelte.js:26:17
❯ Module.render ../../node_modules/@testing-library/svelte/src/pure.js:72:21
❯ src/lib/counter.spec.js:7:
```

## Workaround

To resolve the failure, you can add to `libs/counter/package.json`:

```diff
{
"name": "@svelteunit/counter",
"version": "0.0.1",
"private": true,
- "type": "module"
+ "type": "module",
+ "devDependencies": {
+ "@testing-library/svelte": "^5.2.3"
+ }
}
```
4 changes: 0 additions & 4 deletions libs/counter/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"name": "@svelteunit/counter",
"version": "0.0.1",
"dependencies": {},
"main": "./index.js",
"module": "./index.mjs",
"typings": "./index.d.ts",
"private": true,
"type": "module"
}
13 changes: 0 additions & 13 deletions libs/counter/project.json

This file was deleted.

1 change: 0 additions & 1 deletion libs/counter/src/index.js

This file was deleted.

4 changes: 3 additions & 1 deletion libs/counter/src/lib/counter.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { test } from 'vitest';

import Counter from './counter.svelte';
import { render } from '@testing-library/svelte';

describe('counter', () => {
test('counter', () => {
console.log(render(Counter));
});
5 changes: 0 additions & 5 deletions libs/counter/src/svelte-shims.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions libs/counter/tsconfig.json

This file was deleted.

10 changes: 0 additions & 10 deletions libs/counter/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@ import { svelte } from '@sveltejs/vite-plugin-svelte';
import { svelteTesting } from '@testing-library/svelte/vite';

export default defineConfig({
root: __dirname,
cacheDir: '../../node_modules/.vite/libs/counter',
plugins: [svelte(), svelteTesting()],
test: {
watch: false,
globals: true,
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/libs/counter',
provider: 'v8',
},
},
});
9 changes: 0 additions & 9 deletions nx.json

This file was deleted.

Loading