Skip to content

Commit

Permalink
update svelte templates to use web-test-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 31, 2020
1 parent 33af5f0 commit 7f1690b
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
node-version: '12.x'
- name: yarn install
run: yarn
run: yarn --frozen-lockfile
env:
CI: true
- name: yarn format
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NODE_ENV=test - Needed by "@snowpack/web-test-runner-plugin"
process.env.NODE_ENV = 'test';

module.exports = {
plugins: [require('@snowpack/web-test-runner-plugin')()],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NODE_ENV=test - Needed by "@snowpack/web-test-runner-plugin"
process.env.NODE_ENV = 'test';

module.exports = {
plugins: [require('@snowpack/web-test-runner-plugin')()],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NODE_ENV=test - Needed by "@snowpack/web-test-runner-plugin"
process.env.NODE_ENV = 'test';

module.exports = {
plugins: [require('@snowpack/web-test-runner-plugin')()],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NODE_ENV=test - Needed by "@snowpack/web-test-runner-plugin"
process.env.NODE_ENV = 'test';

module.exports = {
plugins: [require('@snowpack/web-test-runner-plugin')()],
};
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@types/react": "^16.9.49",
"@types/react-dom": "^16.9.8",
"@types/snowpack-env": "^2.3.0",
"@web/test-runner": "^0.9.0",
"@web/test-runner": "^0.9.7",
"chai": "^4.2.0",
"prettier": "^2.0.5",
"snowpack": "^2.16.0",
Expand Down
2 changes: 1 addition & 1 deletion create-snowpack-app/app-template-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@snowpack/plugin-react-refresh": "^2.3.5",
"@snowpack/web-test-runner-plugin": "^0.1.3",
"@testing-library/react": "^11.0.0",
"@web/test-runner": "^0.9.0",
"@web/test-runner": "^0.9.7",
"chai": "^4.2.0",
"prettier": "^2.0.5",
"snowpack": "^2.16.0"
Expand Down

This file was deleted.

This file was deleted.

11 changes: 4 additions & 7 deletions create-snowpack-app/app-template-svelte-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,20 @@
"scripts": {
"start": "snowpack dev",
"build": "snowpack build",
"test": "jest"
"test": "web-test-runner \"src/**/*.test.ts\""
},
"dependencies": {
"svelte": "^3.24.0"
},
"devDependencies": {
"@snowpack/app-scripts-svelte": "^1.9.2",
"@snowpack/plugin-dotenv": "^2.0.4",
"@snowpack/plugin-run-script": "^2.2.0",
"@snowpack/plugin-svelte": "^3.2.0",
"@snowpack/plugin-typescript": "^1.1.0",
"@testing-library/jest-dom": "^5.5.0",
"@snowpack/web-test-runner-plugin": "^0.1.3",
"@testing-library/svelte": "^3.0.0",
"@tsconfig/svelte": "^1.0.3",
"@types/jest": "^26.0.4",
"@types/snowpack-env": "^2.3.0",
"jest": "^26.2.2",
"@web/test-runner": "^0.9.7",
"chai": "^4.2.0",
"snowpack": "^2.16.0",
"svelte-preprocess": "^4.0.8",
"typescript": "^4.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { render } from "@testing-library/svelte";
import App from "./App.svelte";
import {render} from '@testing-library/svelte';
import {expect} from 'chai';
import App from './App.svelte';

test("renders learn svelte link", () => {
const { getByText } = render(App);
const linkElement: HTMLElement = getByText(/learn svelte/i);
expect(linkElement).toBeInTheDocument();
describe('<App>', () => {
it('renders learn svelte link', () => {
const {getByText} = render(App);
const linkElement = getByText(/learn svelte/i);
expect(document.body.contains(linkElement));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NODE_ENV=test - Needed by "@snowpack/web-test-runner-plugin"
process.env.NODE_ENV = 'test';

module.exports = {
plugins: [require('@snowpack/web-test-runner-plugin')()],
};
3 changes: 0 additions & 3 deletions create-snowpack-app/app-template-svelte/jest.config.js

This file was deleted.

5 changes: 0 additions & 5 deletions create-snowpack-app/app-template-svelte/jest.setup.js

This file was deleted.

9 changes: 4 additions & 5 deletions create-snowpack-app/app-template-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@
"scripts": {
"start": "snowpack dev",
"build": "snowpack build",
"test": "jest"
"test": "web-test-runner \"src/**/*.test.js\""
},
"dependencies": {
"svelte": "^3.24.0"
},
"devDependencies": {
"@snowpack/app-scripts-svelte": "^1.9.2",
"@snowpack/plugin-dotenv": "^2.0.4",
"@snowpack/plugin-run-script": "^2.2.0",
"@snowpack/plugin-svelte": "^3.2.0",
"@testing-library/jest-dom": "^5.5.0",
"@snowpack/web-test-runner-plugin": "^0.1.3",
"@testing-library/svelte": "^3.0.0",
"jest": "^26.2.2",
"@web/test-runner": "^0.9.7",
"chai": "^4.2.0",
"snowpack": "^2.16.0"
},
"gitHead": "a01616bb0787d56cd782f94cecf2daa12c7594e4"
Expand Down
15 changes: 9 additions & 6 deletions create-snowpack-app/app-template-svelte/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { render } from "@testing-library/svelte";
import App from "./App";
import {render} from '@testing-library/svelte';
import {expect} from 'chai';
import App from './App.svelte';

test("renders learn svelte link", () => {
const { getByText } = render(App);
const linkElement = getByText(/learn svelte/i);
expect(linkElement).toBeInTheDocument();
describe('<App>', () => {
it('renders learn svelte link', () => {
const {getByText} = render(App);
const linkElement = getByText(/learn svelte/i);
expect(document.body.contains(linkElement));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NODE_ENV=test - Needed by "@snowpack/web-test-runner-plugin"
process.env.NODE_ENV = 'test';

module.exports = {
plugins: [require('@snowpack/web-test-runner-plugin')()],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NODE_ENV=test - Needed by "@snowpack/web-test-runner-plugin"
process.env.NODE_ENV = 'test';

module.exports = {
plugins: [require('@snowpack/web-test-runner-plugin')()],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// NODE_ENV=test - Needed by "@snowpack/web-test-runner-plugin"
process.env.NODE_ENV = 'test';

module.exports = {
plugins: [require('@snowpack/web-test-runner-plugin')()],
};
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function rollupPluginWrapInstallTargets(
return;
}
// Collect and filter all properties of the object as named exports.
return Object.keys(mod).filter((imp) => imp !== 'default');
return Object.keys(mod).filter((imp) => imp !== 'default' && imp !== '__esModule');
} catch (err) {
logger.debug(
`✘ Runtime CJS auto-detection for ${colors.bold(
Expand Down Expand Up @@ -68,7 +68,7 @@ export function rollupPluginWrapInstallTargets(
cjsAutoDetectExportsStatic(require.resolve(e, {paths: [path.dirname(filename)]}), visited),
);
return Array.from(new Set([...exports, ...resolvedReexports])).filter(
(imp) => imp !== 'default',
(imp) => imp !== 'default' && imp !== '__esModule',
);
} catch (err) {
// Safe to ignore, this is usually due to the file not being CJS.
Expand Down
4 changes: 2 additions & 2 deletions plugins/web-test-runner-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"access": "public"
},
"peerDependencies": {
"@web/test-runner": "^0.9.0",
"@web/test-runner": "^0.9.7",
"snowpack": "^2.14.3"
},
"devDependencies": {
"@web/test-runner": "^0.9.0"
"@web/test-runner": "^0.9.7"
},
"gitHead": "a01616bb0787d56cd782f94cecf2daa12c7594e4"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7360,7 +7360,7 @@ exports[`create-snowpack-app app-template-minimal > build: package.json 1`] = `
"{
\\"name\\": \\"@snowpack/app-template-minimal\\",
\\"description\\": \\"A preconfigured minimal template for Snowpack\\",
\\"version\\": \\"1.0.1\\",
\\"version\\": \\"1.0.2\\",
\\"license\\": \\"MIT\\",
\\"homepage\\": \\"https://github.com/snowpackjs/snowpack/tree/master/create-snowpack-app/app-template-preact#readme\\",
\\"repository\\": {
Expand All @@ -7378,7 +7378,7 @@ exports[`create-snowpack-app app-template-minimal > build: package.json 1`] = `
\\"test\\": \\"echo \\\\\\"This template does not include a test runner by default.\\\\\\" && exit 1\\"
},
\\"devDependencies\\": {
\\"snowpack\\": \\"^2.15.1\\"
\\"snowpack\\": \\"^2.16.0\\"
}
}"
`;
Expand Down
9 changes: 2 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2572,11 +2572,6 @@
dependencies:
"@testing-library/dom" "^7.0.3"

"@tsconfig/svelte@^1.0.3":
version "1.0.10"
resolved "https://registry.yarnpkg.com/@tsconfig/svelte/-/svelte-1.0.10.tgz#30ec7feeee0bdf38b12a50f0686f8a2e7b6b9dc0"
integrity sha512-EBrpH2iXXfaf/9z81koiDYkp2mlwW2XzFcAqn6qh7VKyP8zBvHHAQzNhY+W9vH5arAjmGAm5g8ElWq6YmXm3ig==

"@types/aria-query@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.0.tgz#14264692a9d6e2fa4db3df5e56e94b5e25647ac0"
Expand Down Expand Up @@ -2752,7 +2747,7 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@*", "@types/jest@^26.0.4":
"@types/jest@*":
version "26.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe"
integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog==
Expand Down Expand Up @@ -3225,7 +3220,7 @@
"@web/test-runner-core" "^0.8.4"
selenium-webdriver "^4.0.0-alpha.7"

"@web/test-runner@^0.9.0":
"@web/test-runner@^0.9.7":
version "0.9.7"
resolved "https://registry.yarnpkg.com/@web/test-runner/-/test-runner-0.9.7.tgz#f5fdbce3f346c75c3fbc64ddcd8c6e206939f2d1"
integrity sha512-A894e2sgI3aZ7voDMo0o/0ms7oS7NPOb9zui7tMGZt4RUWc4uWduolHd7znAVCTXSJwmlGw8Aa1gWwf4IzAvaQ==
Expand Down

1 comment on commit 7f1690b

@vercel
Copy link

@vercel vercel bot commented on 7f1690b Oct 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.