Skip to content

Commit

Permalink
Cleanup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OrcaXS committed Mar 12, 2018
1 parent 82177ba commit da59881
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 190 deletions.
26 changes: 0 additions & 26 deletions test/e2e/custom-assertions/elementCount.js

This file was deleted.

46 changes: 0 additions & 46 deletions test/e2e/nightwatch.conf.js

This file was deleted.

33 changes: 0 additions & 33 deletions test/e2e/runner.js

This file was deleted.

19 changes: 0 additions & 19 deletions test/e2e/specs/test.js

This file was deleted.

41 changes: 41 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import test from 'ava';
import { Nuxt, Builder } from 'nuxt';
import { resolve } from 'path';

// We keep a reference to Nuxt so we can close
// the server at the end of the test
let nuxt = null;

// Init Nuxt.js and start listening on localhost:4000
test.before('Init Nuxt.js', async (t) => {
const rootDir = resolve(__dirname, '..');
let config = {};
try { config = require(resolve(rootDir, 'nuxt.config.js')) } catch (e) { console.log(`Config error: ${e}`) }
config.rootDir = rootDir; // project folder
config.dev = false; // production build
nuxt = new Nuxt(config);
await new Builder(nuxt).build();
nuxt.listen(4000, 'localhost');
});

// Example of testing only generated html
test('Route / exits and render HTML', async (t) => {
const context = {};
const { html } = await nuxt.renderRoute('/', context);
t.true(html.includes('<h1 class="red">Hello world!</h1>'));
});

// Example of testing via DOM checking
test('Route / exits and render HTML with CSS applied', async (t) => {
const window = await nuxt.renderAndGetWindow('http://localhost:4000/');
const element = window.document.querySelector('.red');
t.not(element, null);
t.is(element.textContent, 'Hello world!');
t.is(element.className, 'red');
t.is(window.getComputedStyle(element).color, 'red');
});

// Close the Nuxt server
test.after('Closing server', (t) => {
nuxt.close();
});
9 changes: 0 additions & 9 deletions test/unit/.eslintrc

This file was deleted.

13 changes: 0 additions & 13 deletions test/unit/index.js

This file was deleted.

33 changes: 0 additions & 33 deletions test/unit/karma.conf.js

This file was deleted.

11 changes: 0 additions & 11 deletions test/unit/specs/Hello.spec.js

This file was deleted.

0 comments on commit da59881

Please sign in to comment.