Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 6 additions & 7 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module.exports = {
file: [
'test/test.js'
'test/test.ts'
],
require: [
'sucrase/register'
]
};

// add coverage options when running 'npx c8 mocha'
if (process.env.NODE_V8_COVERAGE) {
Object.assign(module.exports, {
fullTrace: true,
require: [
'source-map-support/register'
]
});
module.exports.fullTrace = true;
module.exports.require.push('source-map-support/register');
}
3 changes: 2 additions & 1 deletion test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"rules": {
"no-console": "off"
"no-console": "off",
"@typescript-eslint/no-var-requires": "off"
}
}
3 changes: 1 addition & 2 deletions test/css/index.js → test/css/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as assert from 'assert';
import * as fs from 'fs';
import { env, svelte, setupHtmlEqual, shouldUpdateExpected } from '../helpers.js';
import { assert, env, svelte, setupHtmlEqual, shouldUpdateExpected } from '../helpers.ts';

function try_require(file) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as fs from 'fs';
import * as path from 'path';
import * as http from 'http';
import { rollup } from 'rollup';
import * as virtual from '@rollup/plugin-virtual';
import * as puppeteer from 'puppeteer';
import { addLineNumbers, loadConfig, loadSvelte } from "../helpers.js";
import virtual from '@rollup/plugin-virtual';
import puppeteer from 'puppeteer';
import { addLineNumbers, loadConfig, loadSvelte } from "../helpers.ts";
import { deepEqual } from 'assert';

const page = `
Expand Down
7 changes: 4 additions & 3 deletions test/helpers.js → test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as assert$1 from 'assert';
import * as jsdom from 'jsdom';
import * as assert from 'assert';
import * as glob from 'tiny-glob/sync.js';
import glob from 'tiny-glob/sync';
import * as path from 'path';
import * as fs from 'fs';
import * as colors from 'kleur';
export const assert = (assert$1 as unknown) as typeof assert$1 & { htmlEqual: (actual, expected, message?) => void };

// for coverage purposes, we need to test source files,
// but for sanity purposes, we need to test dist files
Expand Down Expand Up @@ -63,7 +64,7 @@ global.window = window;

// add missing ecmascript globals to window
for (const key of Object.getOwnPropertyNames(global)) {
window[key] = window[key] || global[key];
if (!(key in window)) window[key] = global[key];
}

// implement mock scroll
Expand Down
16 changes: 6 additions & 10 deletions test/hydration/index.js → test/hydration/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as assert from 'assert';
import * as path from 'path';
import * as fs from 'fs';

import {
assert,
showOutput,
loadConfig,
loadSvelte,
env,
setupHtmlEqual,
shouldUpdateExpected
} from '../helpers.js';
} from '../helpers.ts';

let compileOptions = null;

Expand Down Expand Up @@ -58,13 +58,7 @@ describe('hydration', () => {
try {
global.window = window;

let SvelteComponent;

try {
SvelteComponent = require(`${cwd}/main.svelte`).default;
} catch (err) {
throw err;
}
const SvelteComponent = require(`${cwd}/main.svelte`).default;

const target = window.document.body;
const head = window.document.head;
Expand All @@ -75,7 +69,9 @@ describe('hydration', () => {
try {
before_head = fs.readFileSync(`${cwd}/_before_head.html`, 'utf-8');
head.innerHTML = before_head;
} catch (err) {}
} catch (err) {
// continue regardless of error
}

const snapshot = config.snapshot ? config.snapshot(target) : {};

Expand Down
2 changes: 1 addition & 1 deletion test/js/index.js → test/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as assert from "assert";
import * as fs from "fs";
import * as path from "path";
import * as colors from "kleur";
import { loadConfig, svelte, shouldUpdateExpected } from "../helpers.js";
import { loadConfig, svelte, shouldUpdateExpected } from "../helpers.ts";

describe("js", () => {
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions test/parser/index.js → test/parser/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as assert from 'assert';
import * as fs from 'fs';
import { svelte, tryToLoadJson, shouldUpdateExpected } from '../helpers.js';
import { svelte, tryToLoadJson, shouldUpdateExpected } from '../helpers.ts';

describe('parse', () => {
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
Expand Down Expand Up @@ -38,7 +38,7 @@ describe('parse', () => {
} catch (err) {
if (err.name !== 'ParseError') throw err;
if (!expectedError) throw err;
const { code, message, pos, start } = err
const { code, message, pos, start } = err;
try {
assert.deepEqual({ code, message, pos, start }, expectedError);
} catch (err2) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/preprocess/index.js → test/preprocess/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as assert from 'assert';
import { loadConfig, svelte } from '../helpers.js';
import { loadConfig, svelte } from '../helpers.ts';

describe('preprocess', () => {
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
Expand Down
8 changes: 4 additions & 4 deletions test/runtime/index.js → test/runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import * as assert from "assert";
import * as path from "path";
import * as fs from "fs";
import { rollup } from 'rollup';
import * as virtual from '@rollup/plugin-virtual';
import * as glob from 'tiny-glob/sync.js';
import virtual from '@rollup/plugin-virtual';
import glob from 'tiny-glob/sync.js';
import { clear_loops, flush, set_now, set_raf } from "../../internal";

import {
assert,
showOutput,
loadConfig,
loadSvelte,
cleanRequireCache,
env,
setupHtmlEqual,
mkdirp
} from "../helpers.js";
} from "../helpers.ts";

let svelte$;
let svelte;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as assert from "assert";
import * as fs from "fs";
import * as path from "path";
import * as glob from 'tiny-glob/sync.js';
import glob from 'tiny-glob/sync.js';

import {
assert,
showOutput,
loadConfig,
loadSvelte,
Expand All @@ -12,7 +12,7 @@ import {
cleanRequireCache,
shouldUpdateExpected,
mkdirp
} from "../helpers.js";
} from "../helpers.ts";

function tryToReadFile(file) {
try {
Expand Down
2 changes: 1 addition & 1 deletion test/sourcemaps/index.js → test/sourcemaps/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from "fs";
import * as path from "path";
import * as assert from "assert";
import { svelte } from "../helpers.js";
import { svelte } from "../helpers.ts";
import { SourceMapConsumer } from "source-map";
import { getLocator } from "locate-character";

Expand Down
2 changes: 1 addition & 1 deletion test/stats/index.js → test/stats/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as assert from 'assert';
import { svelte, loadConfig, tryToLoadJson } from '../helpers.js';
import { svelte, loadConfig, tryToLoadJson } from '../helpers.ts';

describe('stats', () => {
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
Expand Down
4 changes: 2 additions & 2 deletions test/test.js → test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const glob = require('tiny-glob/sync.js');
require('./setup');

// bind internal to jsdom
require('./helpers');
require('./helpers.ts');
require('../internal');

console.clear();

const test_folders = glob('*/index.js', { cwd: 'test' });
const test_folders = glob('*/index.ts', { cwd: 'test' });
const solo_folders = test_folders.filter(folder => /\.solo/.test(folder));

if (solo_folders.length) {
Expand Down
4 changes: 2 additions & 2 deletions test/validator/index.js → test/validator/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from "fs";
import * as assert from "assert";
import { svelte, loadConfig, tryToLoadJson } from "../helpers.js";
import { svelte, loadConfig, tryToLoadJson } from "../helpers.ts";

describe("validate", () => {
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
Expand Down Expand Up @@ -30,7 +30,7 @@ describe("validate", () => {
legacy: config.legacy,
generate: false,
customElement: config.customElement,
...options,
...options
});

assert.deepEqual(warnings.map(w => ({
Expand Down
2 changes: 1 addition & 1 deletion test/vars/index.js → test/vars/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as assert from 'assert';
import { svelte, loadConfig, tryToLoadJson } from '../helpers.js';
import { svelte, loadConfig, tryToLoadJson } from '../helpers.ts';

describe('vars', () => {
fs.readdirSync(`${__dirname}/samples`).forEach(dir => {
Expand Down