-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,705 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Tests for `snowpack dev` | ||
|
||
We moved the tests out of the common `test/` folder because of problems with Windows. This way, we can run the dev tests using a separate command, which we can run on CI on Ubuntu only. | ||
|
||
We would love to figure out the problem. If you develop on a Windows machine, we would appreciate your help. See [#1171](https://github.com/pikapkg/snowpack/pull/1171) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`snowpack dev smoke: html 1`] = ` | ||
"<!DOCTYPE html> | ||
<html lang=\\"en\\"> | ||
<head> | ||
<meta charset=\\"utf-8\\" /> | ||
<link rel=\\"icon\\" href=\\"/favicon.ico\\" /> | ||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1\\" /> | ||
<meta name=\\"description\\" content=\\"Web site created using create-snowpack-app\\" /> | ||
<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"/index.css\\" /> | ||
<title>Snowpack App</title> | ||
<script type=\\"module\\" src=\\"/__snowpack__/hmr-client.js\\"></script><script type=\\"module\\" src=\\"/__snowpack__/hmr-error-overlay.js\\"></script></head> | ||
<body> | ||
<img id=\\"img\\" src=\\"/logo.svg\\" /> | ||
<canvas id=\\"canvas\\"></canvas> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<script type=\\"module\\" src=\\"/_dist_/index.js\\"></script> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run \`npm start\` or \`yarn start\`. | ||
To create a production bundle, use \`npm run build\` or \`yarn build\`. | ||
--> | ||
</body> | ||
</html> | ||
" | ||
`; | ||
exports[`snowpack dev smoke: js 1`] = ` | ||
"/** | ||
* This file is just a silly example to show everything working in the browser. | ||
* When you're ready to start on your site, clear the file. Happy hacking! | ||
**/ | ||
import confetti from '/web_modules/canvas-confetti.js'; | ||
confetti.create(document.getElementById('canvas'), { | ||
resize: true, | ||
useWorker: true, | ||
})({particleCount: 200, spread: 200}); | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const path = require('path'); | ||
|
||
const execa = require('execa'); | ||
const {readdirSync, readFileSync, statSync, existsSync} = require('fs'); | ||
const glob = require('glob'); | ||
const os = require('os'); | ||
const {get} = require('httpie'); | ||
|
||
describe('snowpack dev', () => { | ||
let snowpackProcess; | ||
afterEach(async () => { | ||
snowpackProcess.cancel(); | ||
snowpackProcess.kill('SIGTERM', { | ||
forceKillAfterTimeout: 2000, | ||
}); | ||
|
||
try { | ||
await snowpackProcess; | ||
} catch (error) { | ||
expect(error.killed).toEqual(true); | ||
} | ||
}); | ||
|
||
it('smoke', async () => { | ||
expect.assertions(3); | ||
|
||
const cwd = path.join(__dirname, 'smoke'); | ||
|
||
// start the server | ||
// NOTE: we tried spawning `yarn` here, but the process was not cleaned up | ||
// correctly on CI and the action got stuck. npx does not cause that problem. | ||
snowpackProcess = execa( | ||
path.resolve('node_modules', '.bin', 'snowpack'), | ||
['dev', '--verbose'], | ||
{cwd}, | ||
); | ||
|
||
snowpackProcess.stdout.pipe(process.stdout); | ||
snowpackProcess.stderr.pipe(process.stderr); | ||
|
||
// await server to be ready and set a timeout in case something goes wrong | ||
await new Promise((resolve, reject) => { | ||
// start timeout in case something goes wrong. | ||
const timeout = setTimeout(() => { | ||
snowpackProcess.cancel(); | ||
console.error(output.join('')); | ||
reject(new Error('Timeout: snowpack did not start server within 3 seconds.')); | ||
}, 3000); | ||
|
||
const output = []; | ||
snowpackProcess.stdout.on('data', (buffer) => { | ||
const line = buffer.toString(); | ||
output.push(line); | ||
if (/Server started in/.test(line)) { | ||
resolve(); | ||
clearTimeout(timeout); | ||
} | ||
}); | ||
}); | ||
|
||
// get HTML | ||
const {data: htmlBody} = await get('http://localhost:8080'); | ||
expect(htmlBody).toMatchSnapshot('html'); | ||
|
||
// get built JS | ||
const {data: jsBody} = await get('http://localhost:8080/_dist_/index.js'); | ||
expect(jsBody).toMatchSnapshot('js'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"snowpack": { | ||
"devOptions": { | ||
"open": "none" | ||
}, | ||
"mount": { | ||
"public": "/", | ||
"src": "/_dist_" | ||
} | ||
}, | ||
"dependencies": { | ||
"canvas-confetti": "^1.2.0", | ||
"snowpack": "^2.12.1" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#img { | ||
display: block; | ||
margin: auto; | ||
height: 128px; | ||
width: 128px; | ||
padding: 2rem; | ||
} | ||
|
||
#canvas { | ||
display: block; | ||
margin: 2rem auto; | ||
width: 540px; | ||
height: 540px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="description" content="Web site created using create-snowpack-app" /> | ||
<link rel="stylesheet" type="text/css" href="/index.css" /> | ||
<title>Snowpack App</title> | ||
</head> | ||
<body> | ||
<img id="img" src="/logo.svg" /> | ||
<canvas id="canvas"></canvas> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<script type="module" src="/_dist_/index.js"></script> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* This file is just a silly example to show everything working in the browser. | ||
* When you're ready to start on your site, clear the file. Happy hacking! | ||
**/ | ||
|
||
import confetti from 'canvas-confetti'; | ||
|
||
confetti.create(document.getElementById('canvas'), { | ||
resize: true, | ||
useWorker: true, | ||
})({particleCount: 200, spread: 200}); |
Oops, something went wrong.
65b1193
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: