Skip to content

Commit

Permalink
chore: migrate from jest to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed Oct 14, 2024
1 parent 3109cbf commit 04542c7
Show file tree
Hide file tree
Showing 15 changed files with 266 additions and 11 deletions.
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default [
{
languageOptions: {
globals: {
...globals.jest,
...globals.node,
},
},
Expand Down
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"prepack": "rollup -c",
"prettier": "prettier --check src",
"prettier-write": "prettier --write src",
"test": "npm run test-coverage && npm run eslint",
"test-coverage": "jest --coverage",
"test-only": "jest"
"test": "npm run test-coverage && npm run eslint && npm run prettier",
"test-coverage": "vitest run --coverage",
"test-only": "vitest run"
},
"repository": {
"type": "git",
Expand All @@ -30,22 +30,18 @@
"url": "https://github.com/cheminfo/xps-analysis/issues"
},
"homepage": "https://github.com/cheminfo/xps-analysis#readme",
"jest": {
"testEnvironment": "node"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.25.7",
"@types/jest": "^29.5.13",
"cheminfo-build": "^1.2.0",
"eslint": "^9.12.0",
"eslint-config-cheminfo": "^12.0.1",
"globals": "^15.11.0",
"jest": "^29.7.0",
"openchemlib": "^8.15.0",
"papaparse": "^5.4.1",
"prettier": "^3.3.3",
"rollup": "^4.24.0",
"spectrum-generator": "^8.0.11"
"spectrum-generator": "^8.0.11",
"vitest": "^2.1.3"
},
"dependencies": {
"common-spectrum": "2.12.0",
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { readFileSync } from 'fs';
import { join } from 'path';

import { describe, it, expect } from 'vitest';

import { fromVamas, toJcamp } from '..';

describe('fromVamas', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/peakPicking.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { readFileSync } from 'fs';
import { join } from 'path';

import { describe, it, expect } from 'vitest';

import { fromVamas } from '..';
import { peakPicking } from '../peakPicking';

Expand Down
242 changes: 241 additions & 1 deletion src/from/__tests__/__snapshots__/fromVamas.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,244 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`fromVamas > Cellulose with CASA information, regions and components 1`] = `
{
"analyserMode": "FAT",
"analysisSource": {
"beamWidthX": {
"units": "um",
"value": 6000,
},
"beamWidthY": {
"units": "um",
"value": 500,
},
"characteristicEnergy": {
"units": "eV",
"value": 1486.6,
},
"label": "Al Ka, Monochromated",
},
"components": [
{
"area": {
"lowerBound": 1e-20,
"upperBound": 126904.8,
"value": 4830.0138,
},
"assignment": "C 1s 1",
"atomicMass": 12.011,
"bindingEnergy": {
"units": "eV",
"value": 286.7736,
},
"componentID": "C 1s 1",
"fwhm": {
"lowerBound": 0.25,
"upperBound": 6.25,
"value": 1.1057933,
},
"groupIndex": -1,
"kineticEnergy": {
"units": "eV",
"value": 1199.8264,
},
"position": {
"lowerBound": 1199.7,
"upperBound": 1199.87,
"value": 1199.8264,
},
"relativeSensitivityFactor": 0.278,
"shape": {
"kind": "lorentzianAsymmetric",
"options": {
"alpha": 1.4,
"beta": 1.7,
"m": 100,
},
},
"uncorrectedRSF": 0.278,
},
{
"area": {
"constrain": {
"factor": 0.2048,
"linkedComponent": 0,
},
"lowerBound": 0,
"upperBound": 2000,
"value": 989.18682,
},
"assignment": "C 1s 2",
"atomicMass": 12.011,
"bindingEnergy": {
"units": "eV",
"value": 288.1950999999999,
},
"componentID": "C 1s 2",
"fwhm": {
"lowerBound": 0.25,
"upperBound": 6.25,
"value": 1.1121055,
},
"groupIndex": -1,
"kineticEnergy": {
"units": "eV",
"value": 1198.4049,
},
"position": {
"lowerBound": 1198.34,
"upperBound": 1198.74,
"value": 1198.4049,
},
"relativeSensitivityFactor": 0.278,
"shape": {
"kind": "lorentzianAsymmetric",
"options": {
"alpha": 1.4,
"beta": 1.6,
"m": 100,
},
},
"uncorrectedRSF": 0.278,
},
{
"area": {
"lowerBound": 0,
"upperBound": 243,
"value": 56.812945,
},
"assignment": "C 1s degrad",
"atomicMass": 12.011,
"bindingEnergy": {
"units": "eV",
"value": 288.8453999999999,
},
"componentID": "C 1s degrad",
"fwhm": {
"lowerBound": 0.25,
"upperBound": 2,
"value": 0.82920074,
},
"groupIndex": -1,
"kineticEnergy": {
"units": "eV",
"value": 1197.7546,
},
"position": {
"lowerBound": 1197.3546,
"upperBound": 1197.7546,
"value": 1197.7546,
},
"relativeSensitivityFactor": 0.278,
"shape": {
"kind": "gaussianLorentzianProduct",
"options": {
"mixingRatio": 30,
},
},
"uncorrectedRSF": 0.278,
},
{
"area": {
"lowerBound": 1e-20,
"upperBound": 126904.8,
"value": 100.40835,
},
"assignment": "C 1s Adv.C",
"atomicMass": 12.011,
"bindingEnergy": {
"units": "eV",
"value": 284.8711999999998,
},
"componentID": "C 1s Adv.C",
"fwhm": {
"lowerBound": 0.25,
"upperBound": 6.25,
"value": 0.74742285,
},
"groupIndex": -1,
"kineticEnergy": {
"units": "eV",
"value": 1201.7288,
},
"position": {
"lowerBound": 1201.4,
"upperBound": 1201.8,
"value": 1201.7288,
},
"relativeSensitivityFactor": 0.278,
"shape": {
"kind": "gaussianLorentzianProduct",
"options": {
"mixingRatio": 30,
},
},
"uncorrectedRSF": 0.278,
},
],
"energyType": {
"kind": "binding",
"units": "eV",
},
"from": 294.16,
"region": {
"auger": {
"element": null,
"transition": null,
},
"name": "C 1s",
"orbital": {
"angularMomentum": "s",
"element": "C",
"shell": 1,
},
},
"regions": [
{
"background": {
"parameters": {
"averageWidth": 1,
"bindingEnergyEnd": {
"units": "eV",
"value": 283.34839999999986,
},
"bindingEnergyStart": {
"units": "eV",
"value": 293.2871,
},
"crossSection": [
40.442441,
-450,
0,
0,
],
"endOffset": 0,
"kineticEnergyEnd": {
"units": "eV",
"value": 1203.2516,
},
"kineticEnergyStart": {
"units": "eV",
"value": 1193.3129,
},
"relativeSensitivityFactor": 0.278,
"startOffset": 0,
},
"rawParameters": "1193.3129 1203.2516 0.278 2 0 0 40.442441 -450 0 0",
"type": "Shirley",
},
"block": {
"atomicMass": 12.011,
"regionBlockID": "C 1s",
"relativeSensitivityFactor": 0.278,
},
"regionID": "C 1s",
},
],
"speciesLabel": "C",
"to": 282.16,
}
`;

exports[`fromVamas Cellulose with CASA information, regions and components 1`] = `
{
Expand Down
2 changes: 2 additions & 0 deletions src/from/__tests__/fromVamas.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { readFileSync } from 'fs';
import { join } from 'path';

import { describe, it, expect } from 'vitest';

import { fromVamas } from '../fromVamas';

describe('fromVamas', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/from/__tests__/getNormalizedMeta.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { test, expect } from 'vitest';

import { getNormalizedMeta } from '../getNormalizedMeta';

import meta from './meta.json';
Expand Down
1 change: 1 addition & 0 deletions src/from/__tests__/mapComponents.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parseCASA } from 'vamas';
import { describe, it, expect } from 'vitest';

import { mapComponents } from '../mapComponents';

Expand Down
2 changes: 2 additions & 0 deletions src/from/__tests__/parseRegion.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, it, expect } from 'vitest';

import { parseRegion } from '../parseRegion.js';

describe('XPS region parser', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utilities/background/__tests__/appendBackground.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { readFileSync } from 'fs';
import { join } from 'path';

import { test } from 'vitest';

import { fromVamas } from '../../../from/fromVamas.js';
import { appendBackground } from '../appendBackground.js';

Expand Down
2 changes: 2 additions & 0 deletions src/utilities/background/__tests__/linear.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { test, expect } from 'vitest';

import { linear } from '../linear';

test('linear', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/utilities/background/__tests__/shirley.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { test, expect } from 'vitest';

import { shirley } from '../shirley';

test('shirley', () => {
Expand Down
1 change: 1 addition & 0 deletions src/utilities/prediction/__tests__/predictPolymer.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Molecule } from 'openchemlib';
import { test } from 'vitest';

import { predictPolymer } from '../predictPolymer';

Expand Down
1 change: 1 addition & 0 deletions src/utilities/prediction/__tests__/predictUsingAI.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import OCL from 'openchemlib';
import { test, expect } from 'vitest';

import { predictUsingAI } from '../predictUsingAI.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import OCL from 'openchemlib';
import { test, expect } from 'vitest';

import { predictUsingHoseCodes } from '../predictUsingHoseCodes.js';

Expand Down

0 comments on commit 04542c7

Please sign in to comment.