Skip to content

Commit b0a4682

Browse files
committed
refactor: simplify test exec packages/cashc
- remove tests scripts from package.json - delete tsconfig.test.json config file no longer needed - add vitest api as global so that import is no required such as describe, expect, it, etc.
1 parent 173c0e6 commit b0a4682

File tree

9 files changed

+7
-22
lines changed

9 files changed

+7
-22
lines changed

packages/cashc/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,11 @@
3939
"antlr": "antlr -Dlanguage=TypeScript -visitor -no-listener src/grammar/CashScript.g4",
4040
"postantlr": "find src/grammar -type f -name 'CashScriptVisitor.ts' | xargs sed -i '' 's|\\(import .* \".*/.*\\)\";|\\1\\.js\";|g'",
4141
"build": "yarn clean && yarn compile",
42-
"build:test": "yarn clean:test && yarn compile:test && cpy './test/**/*.cash' ./dist-test/test",
4342
"clean": "rm -rf ./dist",
44-
"clean:test": "rm -rf ./dist-test",
4543
"compile": "tsc -p tsconfig.build.json",
46-
"compile:test": "tsc -p tsconfig.test.json",
4744
"lint": "eslint . --ext .ts --ignore-path ../../.eslintignore",
4845
"prepare": "yarn build",
4946
"prepublishOnly": "yarn test && yarn lint",
50-
"pretest": "yarn build:test",
5147
"test": "vitest run"
5248
},
5349
"dependencies": {

packages/cashc/test/ast/AST.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { parseCode } from '../../src/compiler.js';
1717
import { readCashFiles } from '../test-utils.js';
1818
import { Ast } from '../../src/ast/AST.js';
1919
import OutputSourceCodeTraversal from '../../src/print/OutputSourceCodeTraversal.js';
20-
import { describe, expect, it } from 'vitest';
20+
2121

2222
const VALID_CONTRACT_FILES = new URL('../valid-contract-files', import.meta.url);
2323

packages/cashc/test/ast/Location.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { URL } from 'url';
33
import { compileString, parseCode } from '../../src/compiler.js';
44
import { buildLineToAsmMap, bytecodeToAsm, bytecodeToScript } from '@cashscript/utils';
55
import { hexToBin } from '@bitauth/libauth';
6-
import { describe, expect, it } from 'vitest';
6+
77

88
describe('Location', () => {
99
it('should retrieve correct text from location', () => {

packages/cashc/test/compiler/compiler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { URL } from 'url';
99
import { getSubdirectories, readCashFiles } from '../test-utils.js';
1010
import * as Errors from '../../src/Errors.js';
1111
import { compileString } from '../../src/index.js';
12-
import { describe, expect, it } from 'vitest';
12+
1313

1414
describe('Compiler', () => {
1515
describe('Successful compilation', () => {

packages/cashc/test/debugging/debugging.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { URL } from 'url';
77
import { compileFile } from '../../src/index.js';
88
import { fixtures } from './fixtures.js';
9-
import { describe, expect, it } from 'vitest';
9+
1010

1111
describe('Debugging', () => {
1212
fixtures.forEach((fixture) => {

packages/cashc/test/generation/generation.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { URL } from 'url';
77
import { compileFile } from '../../src/index.js';
88
import { fixtures } from './fixtures.js';
9-
import { describe, it, expect } from 'vitest';
109

1110
describe('Code generation & target code optimisation', () => {
1211
fixtures.forEach((fixture) => {

packages/cashc/tsconfig.build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"compilerOptions": {
55
"outDir": "./dist",
6+
"types": ["vitest/globals"]
67
},
78

89
"include": [

packages/cashc/tsconfig.test.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/cashc/vitest.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { defineConfig } from 'vitest/config';
22

33
export default defineConfig({
4-
root: './dist-test',
4+
root: './test',
55
test: {
66
environment: 'node',
7+
globals: true,
78
silent: 'passed-only',
89
include: ['**/*.{test,spec}.?(c|m)[jt]s?(x)'],
910
setupFiles: ['./vitest.setup.ts'],

0 commit comments

Comments
 (0)