Created
May 17, 2017 02:52
-
-
Save SunKing2/7d7a5d86008cd07cc026c03dfc648ec6 to your computer and use it in GitHub Desktop.
test dom with ava, using nodejs, this is a script which creates an environment under linux (needs yarn, perl)
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
rm package.json | |
rm -f package.json.original | |
rm -r node_modules | |
rm -r test | |
yarn init -y | |
yarn add ava browser-env -D | |
perl -0777 -i.original -pe 's/aaa/bbb/igs' package.json | |
perl -0777 -i.original -pe 's/"license": "MIT",/"license": "MIT",\n "scripts": \{\n "test": "ava --verbose"\n\n },\n "ava": \{\n "require": [\n ".\/setup-browser-env.js"\n ]\n },\n/igs' package.json | |
cat > setup-browser-env.js <<EOL | |
require('browser-env')() | |
EOL | |
mkdir test | |
cat >test/test1.js <<EOL | |
import test from 'ava'; | |
test('can query for DOM elements', t => { | |
document.body.innerHTML = '<p>Hello, world</p>'; | |
const para = document.querySelector('p'); | |
t.is(para.innerHTML, 'Hello, world'); | |
}); | |
EOL | |
yarn test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment