@forgehive/record-tape 0.1.6 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,48 +1,36 @@
1
1
  import { RecordTape } from '../index'
2
2
 
3
- const baseTapeData = [
4
- {
5
- name: 'name',
6
- type: 'success',
7
- input: [true],
8
- output: true,
9
- boundaries: {}
10
- },
11
- {
12
- name: 'name',
13
- type: 'error',
14
- input: [true],
15
- error: 'invalid data',
16
- boundaries: {}
17
- }
18
- ]
19
-
20
- const logFileData = '{"name":"name","type":"success","input":[true],"output":true,"boundaries":{}}\n{"name":"name","type":"error","input":[true],"error":"invalid data","boundaries":{}}\n'
21
-
22
- describe('Log format', () => {
23
- it('Should ensure format', () => {
24
- type InputType = boolean[]
3
+ describe('Test log item formating', () => {
4
+ it('Should format a log items into valid JSON', async () => {
5
+ type InputType = boolean
25
6
  type OutputType = boolean
26
7
 
27
8
  const tape = new RecordTape<InputType, OutputType>({})
9
+ tape.push({ input: true, output: true, boundaries: {}, type: 'success', taskName: 'name' })
10
+ tape.push({ input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name' })
28
11
 
29
- tape.addLogItem('name', { input: [true], output: true, boundaries: {} })
30
- tape.addLogItem('name', { input: [true], error: 'invalid data', boundaries: {} })
12
+ const str = tape.stringify()
31
13
 
32
- expect(tape.getLog()).toEqual(baseTapeData)
14
+ expect(str).toEqual(`{"input":true,"output":true,"boundaries":{},"type":"success","taskName":"name","metadata":{}}
15
+ {"input":true,"error":"invalid data","boundaries":{},"type":"error","taskName":"name","metadata":{}}
16
+ `)
33
17
  })
34
18
 
35
- it('Should serialize to one line per item', () => {
36
- type InputType = boolean[]
19
+ it('Should parse the string to a list of records', async () => {
20
+ type InputType = boolean
37
21
  type OutputType = boolean
38
22
 
39
23
  const tape = new RecordTape<InputType, OutputType>({})
24
+ tape.push({ input: true, output: true, boundaries: {}, type: 'success', taskName: 'name' })
25
+ tape.push({ input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name' })
40
26
 
41
- tape.addLogItem('name', { input: [true], output: true, boundaries: {} })
42
- tape.addLogItem('name', { input: [true], error: 'invalid data', boundaries: {} })
27
+ const str = tape.stringify()
28
+ const tape2 = new RecordTape<InputType, OutputType>({})
29
+ const records = tape2.parse(str)
43
30
 
44
- const logFile = tape.stringify()
45
-
46
- expect(logFile).toBe(logFileData)
31
+ expect(records).toEqual([
32
+ { input: true, output: true, boundaries: {}, type: 'success', taskName: 'name', metadata: {} },
33
+ { input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name', metadata: {} }
34
+ ])
47
35
  })
48
36
  })
@@ -1,345 +1,170 @@
1
- import { RecordTape, type LogItem } from '../index'
2
- import { createTask, Schema, type ExecutionRecord, type TaskRecord } from '@forgehive/task'
3
-
4
- describe('RecordTape safeRun integration tests', () => {
5
- it('should record log items directly from safeRun result', async () => {
6
- // Create a schema
7
- const schema = new Schema({
8
- value: Schema.number()
9
- })
10
-
11
- // Define the boundaries
12
- const boundaries = {
13
- fetchData: async (value: number): Promise<number> => {
14
- return value * 2
1
+ import { createTask, Schema } from '@forgehive/task'
2
+ import { RecordTape } from '../index'
3
+
4
+ describe('Safe run', () => {
5
+ it('Should run a simple task with no boundaries and register to a tape', async () => {
6
+ const tape = new RecordTape<{ value: number }, { doubled: number }>({})
7
+
8
+ const task = createTask({
9
+ name: 'simple-task',
10
+ schema: new Schema({
11
+ value: Schema.number()
12
+ }),
13
+ boundaries: {},
14
+ fn: async ({ value }) => {
15
+ return { doubled: value * 2 }
15
16
  }
16
- }
17
-
18
- // Create the task
19
- const task = createTask(
20
- schema,
21
- boundaries,
22
- async function ({ value }, { fetchData }) {
23
- const result = await fetchData(value)
24
- return { result, success: true }
25
- }
26
- )
27
-
28
- // Create a record tape
29
- const tape = new RecordTape<{ value: number }, { result: number; success: boolean }, typeof boundaries>()
30
-
31
- // Run the task with safeRun and directly use the logItem
32
- const [result, error, record] = await task.safeRun({ value: 5 })
33
- tape.push('test-task', record)
34
-
35
- // Verify the execution was successful
36
- expect(error).toBeNull()
37
- expect(result).toEqual({ result: 10, success: true })
38
-
39
- // Get the recorded log from the tape
40
- const recordedLog = tape.getLog()
41
-
42
- // Verify the log was recorded correctly
43
- expect(recordedLog).toHaveLength(1)
44
-
45
- const logItem = recordedLog[0]
46
- expect(logItem.name).toEqual('test-task')
47
- expect(logItem.type).toEqual('success')
48
- expect(logItem.input).toEqual({ value: 5 })
49
- expect(logItem.output).toEqual({ result: 10, success: true })
50
- expect(logItem.boundaries).toEqual({
51
- fetchData: [{
52
- input: [5],
53
- output: 10,
54
- error: null
55
- }]
56
17
  })
57
- })
58
-
59
- it('should record log items from safeRun successfully', async () => {
60
- // Create a schema
61
- const schema = new Schema({
62
- value: Schema.number()
63
- })
64
-
65
- // Define the boundaries
66
- const boundaries = {
67
- fetchData: async (value: number): Promise<number> => {
68
- return value * 2
69
- }
70
- }
71
-
72
- // Create the task
73
- const task = createTask(
74
- schema,
75
- boundaries,
76
- async function ({ value }, { fetchData }) {
77
- const result = await fetchData(value)
78
- return { result, success: true }
79
- }
80
- )
81
-
82
- // Create a record tape
83
- const tape = new RecordTape<{ value: number }, { result: number; success: boolean }, typeof boundaries>()
84
-
85
- // Add listener to record the log items
86
- task.addListener((record: TaskRecord<{ value: number }, { result: number; success: boolean }>) => {
87
- // Manually ensure boundary records have error field for consistency with safeRun
88
- if (record.boundaries && record.boundaries.fetchData && Array.isArray(record.boundaries.fetchData)) {
89
- record.boundaries.fetchData = record.boundaries.fetchData.map((entry: Record<string, unknown>) => ({
90
- ...entry,
91
- error: entry.error ?? null,
92
- output: entry.output ?? null
93
- }))
94
- }
95
18
 
96
- // Cast the record to LogItem type to satisfy TypeScript
97
- tape.addLogItem('test-task', record as unknown as LogItem<{ value: number }, { result: number; success: boolean }>)
19
+ task.addListener((record) => {
20
+ tape.push(record)
98
21
  })
99
22
 
100
- // Run the task with safeRun
23
+ // Test simple execution
101
24
  const [result, error] = await task.safeRun({ value: 5 })
102
25
 
103
- // Verify the execution was successful
104
26
  expect(error).toBeNull()
105
- expect(result).toEqual({ result: 10, success: true })
106
-
107
- // Get the recorded log from the tape
108
- const recordedLog = tape.getLog()
27
+ expect(result).toEqual({ doubled: 10 })
109
28
 
110
- // Verify the log was recorded correctly
111
- expect(recordedLog).toHaveLength(1)
112
- expect(recordedLog[0]).toEqual({
113
- name: 'test-task',
29
+ const log = tape.getLog()
30
+ expect(log).toHaveLength(1)
31
+ expect(log[0]).toEqual({
114
32
  type: 'success',
115
33
  input: { value: 5 },
116
- output: { result: 10, success: true },
117
- boundaries: {
118
- fetchData: [{
119
- input: [5],
120
- output: 10,
121
- error: null
122
- }]
123
- }
34
+ output: { doubled: 10 },
35
+ boundaries: {},
36
+ metadata: {},
37
+ taskName: 'simple-task'
124
38
  })
125
39
  })
126
40
 
127
- it('should record error log items from safeRun', async () => {
128
- // Create a schema
129
- const schema = new Schema({
130
- value: Schema.number()
131
- })
41
+ it('Should run a task with boundaries and register to a tape', async () => {
42
+ const tape = new RecordTape<{ value: number }, { result: number; success: boolean }>({})
132
43
 
133
- // Define the boundaries with a function that will throw an error
134
- const boundaries = {
135
- fetchData: async (value: number): Promise<number> => {
136
- if (value < 0) {
137
- throw new Error('Value cannot be negative')
44
+ const task = createTask({
45
+ name: 'test',
46
+ schema: new Schema({
47
+ value: Schema.number().min(10).max(20)
48
+ }),
49
+ boundaries: {
50
+ multiply: async (value: number): Promise<number> => {
51
+ return value * 2
138
52
  }
139
- return value * 2
140
- }
141
- }
142
-
143
- // Create the task
144
- const task = createTask(
145
- schema,
146
- boundaries,
147
- async function ({ value }, { fetchData }) {
148
- const result = await fetchData(value)
149
- return { result, success: true }
150
- }
151
- )
152
-
153
- // Create a record tape
154
- const tape = new RecordTape<{ value: number }, { result: number; success: boolean }, typeof boundaries>()
155
-
156
- // Add listener to record the log items
157
- task.addListener((record: TaskRecord<{ value: number }, { result: number; success: boolean }>) => {
158
- // Manually ensure boundary records have error field for consistency with safeRun
159
- if (record.boundaries && record.boundaries.fetchData && Array.isArray(record.boundaries.fetchData)) {
160
- record.boundaries.fetchData = record.boundaries.fetchData.map((entry: Record<string, unknown>) => ({
161
- ...entry,
162
- error: entry.error ?? null,
163
- output: entry.output ?? null
164
- }))
53
+ },
54
+ fn: async ({ value }, { multiply }) => {
55
+ const result = await multiply(value)
56
+ return { result, success: result > 10 }
165
57
  }
58
+ })
166
59
 
167
- // Cast the record to LogItem type to satisfy TypeScript
168
- tape.addLogItem('test-task', record as unknown as LogItem<{ value: number }, { result: number; success: boolean }>)
60
+ task.addListener((record) => {
61
+ tape.push(record)
169
62
  })
170
63
 
171
- // Run the task with safeRun with a value that will cause an error
172
- const [result, error] = await task.safeRun({ value: -5 })
64
+ // Test invalid input
65
+ let [result, error] = await task.safeRun({ value: 5 })
173
66
 
174
- // Verify the execution failed as expected
175
- expect(result).toBeNull()
176
- expect(error).not.toBeNull()
177
- expect(error?.message).toContain('Value cannot be negative')
67
+ expect(error).toBeDefined()
68
+ expect(error?.message).toContain('Invalid input')
178
69
 
179
- // Get the recorded log from the tape
180
- const recordedLog = tape.getLog()
70
+ // Test valid input
71
+ ;[result, error] = await task.safeRun({ value: 15 })
72
+ expect(error).toBeNull()
73
+ expect(result).toEqual({ result: 30, success: true })
181
74
 
182
- // Verify the error log was recorded correctly
183
- expect(recordedLog).toHaveLength(1)
184
- expect(recordedLog[0]).toEqual({
185
- name: 'test-task',
75
+ const log = tape.getLog()
76
+ expect(log).toHaveLength(2)
77
+ expect(log[0]).toEqual({
186
78
  type: 'error',
187
- input: { value: -5 },
188
- error: 'Value cannot be negative',
79
+ input: { value: 5 },
80
+ error: 'Invalid input on: value: Number must be greater than or equal to 10',
189
81
  boundaries: {
190
- fetchData: [{
191
- input: [-5],
192
- error: 'Value cannot be negative',
193
- output: null
82
+ multiply: []
83
+ },
84
+ metadata: {},
85
+ taskName: 'test'
86
+ })
87
+
88
+ expect(log[1]).toEqual({
89
+ type: 'success',
90
+ input: { value: 15 },
91
+ output: { result: 30, success: true },
92
+ boundaries: {
93
+ multiply: [{
94
+ input: [15],
95
+ output: 30
194
96
  }]
195
- }
97
+ },
98
+ metadata: {},
99
+ taskName: 'test'
196
100
  })
197
101
  })
198
102
 
199
- it('should handle error records directly with push', async () => {
200
- // Create a schema
201
- const schema = new Schema({
202
- value: Schema.number()
203
- })
103
+ it('Should run a task with boundaries and register errors to a tape', async () => {
104
+ const tape = new RecordTape<{ value: number }, { result: number }>({})
204
105
 
205
- // Define the boundaries with a function that will throw an error
206
- const boundaries = {
207
- fetchData: async (value: number): Promise<number> => {
208
- if (value < 0) {
209
- throw new Error('Value cannot be negative')
106
+ const task = createTask({
107
+ name: 'test',
108
+ schema: new Schema({
109
+ value: Schema.number()
110
+ }),
111
+ boundaries: {
112
+ divide: async (value: number): Promise<number> => {
113
+ if (value === 0) {
114
+ throw new Error('Division by zero')
115
+ }
116
+ return 100 / value
210
117
  }
211
- return value * 2
212
- }
213
- }
214
-
215
- // Create the task
216
- const task = createTask(
217
- schema,
218
- boundaries,
219
- async function ({ value }, { fetchData }) {
220
- const result = await fetchData(value)
221
- return { result, success: true }
118
+ },
119
+ fn: async ({ value }, { divide }) => {
120
+ const result = await divide(value)
121
+ return { result }
222
122
  }
223
- )
224
-
225
- // Create a record tape
226
- const tape = new RecordTape<{ value: number }, { result: number; success: boolean }, typeof boundaries>()
123
+ })
227
124
 
228
- // Run the task with safeRun with a value that will cause an error
229
- const [result, error, record] = await task.safeRun({ value: -5 })
125
+ task.addListener((record) => {
126
+ tape.push(record)
127
+ })
230
128
 
231
- // Push the error record directly with type parameter
232
- tape.push('test-error', record)
129
+ // Test division by zero
130
+ const [, error] = await task.safeRun({ value: 0 })
233
131
 
234
- // Verify the execution failed as expected
235
- expect(result).toBeNull()
236
- expect(error).not.toBeNull()
237
- expect(error instanceof Error).toBe(true)
238
- if (error instanceof Error) {
239
- expect(error.message).toContain('Value cannot be negative')
240
- }
132
+ expect(error).toBeDefined()
133
+ expect(error?.message).toBe('Division by zero')
241
134
 
242
- // Get the recorded log from the tape
243
- const recordedLog = tape.getLog()
135
+ // Test valid input
136
+ const [secondResult, secondError] = await task.safeRun({ value: 10 })
137
+ expect(secondError).toBeNull()
138
+ expect(secondResult).toEqual({ result: 10 })
244
139
 
245
- // Verify the error log was recorded correctly
246
- expect(recordedLog).toHaveLength(1)
247
- expect(recordedLog[0]).toEqual({
248
- name: 'test-error',
140
+ const log = tape.getLog()
141
+ expect(log).toHaveLength(2)
142
+ expect(log[0]).toEqual({
249
143
  type: 'error',
250
- input: { value: -5 },
251
- error: 'Value cannot be negative',
144
+ input: { value: 0 },
145
+ error: 'Division by zero',
252
146
  boundaries: {
253
- fetchData: [{
254
- input: [-5],
255
- output: null,
256
- error: 'Value cannot be negative'
147
+ divide: [{
148
+ input: [0],
149
+ error: 'Division by zero'
257
150
  }]
258
- }
151
+ },
152
+ metadata: {},
153
+ taskName: 'test'
259
154
  })
260
- })
261
155
 
262
- it('should handle custom execution records with push', async () => {
263
- // Create a record tape
264
- const tape = new RecordTape<{ value: number }, { result: number }, { fetchData: (n: number) => Promise<number> }>()
265
-
266
- // Create a custom execution record
267
- const customRecord: ExecutionRecord<{ value: number }, { result: number }, { fetchData: (n: number) => Promise<number> }> = {
268
- input: { value: 10 },
269
- output: { result: 20 },
270
- boundaries: {
271
- fetchData: [
272
- {
273
- input: [10],
274
- output: 20
275
- }
276
- ]
277
- }
278
- }
279
-
280
- // Push the custom record
281
- tape.push('custom-record', customRecord)
282
-
283
- // Get the recorded log from the tape
284
- const recordedLog = tape.getLog()
285
-
286
- // Verify the log was recorded correctly
287
- expect(recordedLog).toHaveLength(1)
288
- expect(recordedLog[0]).toEqual({
289
- name: 'custom-record',
156
+ expect(log[1]).toEqual({
290
157
  type: 'success',
291
158
  input: { value: 10 },
292
- output: { result: 20 },
159
+ output: { result: 10 },
293
160
  boundaries: {
294
- fetchData: [{
161
+ divide: [{
295
162
  input: [10],
296
- output: 20,
297
- error: null
163
+ output: 10
298
164
  }]
299
165
  },
300
- context: undefined
301
- })
302
- })
303
-
304
- it('should handle execution records with Promise outputs correctly', async () => {
305
- // Create a record tape
306
- const tape = new RecordTape<{ value: number }, { result: number }, { fetchData: (n: number) => Promise<number> }>()
307
-
308
- // Create a custom execution record with a Promise output
309
- const promiseResult = Promise.resolve({ result: 30 })
310
- const promiseRecord: ExecutionRecord<{ value: number }, Promise<{ result: number }>, { fetchData: (n: number) => Promise<number> }> = {
311
- input: { value: 15 },
312
- output: promiseResult,
313
- boundaries: {
314
- fetchData: [
315
- {
316
- input: [15],
317
- output: 30
318
- }
319
- ]
320
- }
321
- }
322
-
323
- // Push the record with Promise output using type parameter
324
- tape.push('promise-record', promiseRecord)
325
-
326
- // Get the recorded log from the tape
327
- const recordedLog = tape.getLog()
328
-
329
- // Verify the log was recorded correctly, with Promise output set to null
330
- expect(recordedLog).toHaveLength(1)
331
- expect(recordedLog[0]).toEqual({
332
- name: 'promise-record',
333
- type: 'success',
334
- input: { value: 15 },
335
- output: null, // Promise output should be set to null
336
- boundaries: {
337
- fetchData: [{
338
- input: [15],
339
- output: 30,
340
- error: null
341
- }]
342
- }
166
+ metadata: {},
167
+ taskName: 'test'
343
168
  })
344
169
  })
345
170
  })
@@ -2,11 +2,11 @@ import fs from 'fs'
2
2
  import path from 'path'
3
3
  import { RecordTape } from '../index'
4
4
 
5
- const logFileData = '{"name":"name","type":"success","input":[true],"output":true,"boundaries":{}}\n{"name":"name","type":"error","input":[true],"error":"invalid data","boundaries":{}}\n'
5
+ const logFileData = '{"input":true,"output":true,"boundaries":{},"type":"success","taskName":"name","metadata":{}}\n{"input":true,"error":"invalid data","boundaries":{},"type":"error","taskName":"name","metadata":{}}\n'
6
6
 
7
7
  describe('Save to file async', () => {
8
8
  it('Save async to existing file(should add new logs)', async () => {
9
- type InputType = boolean[]
9
+ type InputType = boolean
10
10
  type OutputType = boolean
11
11
 
12
12
  const tapeFilePath = path.resolve(__dirname, './fixtures/save')
@@ -19,8 +19,8 @@ describe('Save to file async', () => {
19
19
 
20
20
  const tape = new RecordTape<InputType, OutputType>({ path: tapeFilePath })
21
21
  await tape.load()
22
- tape.addLogItem('name', { input: [true], output: true, boundaries: {} })
23
- tape.addLogItem('name', { input: [true], error: 'invalid data', boundaries: {} })
22
+ tape.push({ input: true, output: true, boundaries: {}, type: 'success', taskName: 'name' })
23
+ tape.push({ input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name' })
24
24
  await tape.save()
25
25
 
26
26
  const content = await fs.promises.readFile(tapeFilePath + '.log', 'utf8')
@@ -31,20 +31,20 @@ describe('Save to file async', () => {
31
31
  })
32
32
 
33
33
  it('Save async to a path of invalid folder', async () => {
34
- type InputType = boolean[]
34
+ type InputType = boolean
35
35
  type OutputType = boolean
36
36
 
37
37
  const tapeFilePath = path.resolve(__dirname, './nowhere/nop')
38
38
 
39
39
  const tape = new RecordTape<InputType, OutputType>({ path: tapeFilePath })
40
- tape.addLogItem('name', { input: [true], output: true, boundaries: {} })
41
- tape.addLogItem('name', { input: [true], error: 'invalid data', boundaries: {} })
40
+ tape.push({ input: true, output: true, boundaries: {}, type: 'success', taskName: 'name' })
41
+ tape.push({ input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name' })
42
42
 
43
43
  await expect(tape.save()).rejects.toThrow('Folder doesn\'t exists')
44
44
  })
45
45
 
46
46
  it('Save async to a log file that doesnt exist', async () => {
47
- type InputType = boolean[]
47
+ type InputType = boolean
48
48
  type OutputType = boolean
49
49
 
50
50
  const tapeFilePath = path.resolve(__dirname, './fixtures/nop')
@@ -56,8 +56,8 @@ describe('Save to file async', () => {
56
56
  }
57
57
 
58
58
  const tape = new RecordTape<InputType, OutputType>({ path: tapeFilePath })
59
- tape.addLogItem('name', { input: [true], output: true, boundaries: {} })
60
- tape.addLogItem('name', { input: [true], error: 'invalid data', boundaries: {} })
59
+ tape.push({ input: true, output: true, boundaries: {}, type: 'success', taskName: 'name' })
60
+ tape.push({ input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name' })
61
61
  await tape.save()
62
62
 
63
63
  const content = await fs.promises.readFile(tapeFilePath + '.log', 'utf8')
@@ -68,7 +68,7 @@ describe('Save to file async', () => {
68
68
 
69
69
  describe('Save to file sync', () => {
70
70
  it('Save sync', () => {
71
- type InputType = boolean[]
71
+ type InputType = boolean
72
72
  type OutputType = boolean
73
73
 
74
74
  const tapeFilePath = path.resolve(__dirname, './fixtures/save')
@@ -80,8 +80,8 @@ describe('Save to file sync', () => {
80
80
  }
81
81
 
82
82
  const tape = new RecordTape<InputType, OutputType>({ path: tapeFilePath })
83
- tape.addLogItem('name', { input: [true], output: true, boundaries: {} })
84
- tape.addLogItem('name', { input: [true], error: 'invalid data', boundaries: {} })
83
+ tape.push({ input: true, output: true, boundaries: {}, type: 'success', taskName: 'name' })
84
+ tape.push({ input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name' })
85
85
  tape.saveSync()
86
86
 
87
87
  const content = fs.readFileSync(tapeFilePath + '.log', 'utf8')
@@ -90,20 +90,20 @@ describe('Save to file sync', () => {
90
90
  })
91
91
 
92
92
  it('Save sync to a path of invalid folder', () => {
93
- type InputType = boolean[]
93
+ type InputType = boolean
94
94
  type OutputType = boolean
95
95
 
96
96
  const tapeFilePath = path.resolve(__dirname, './nowhere/nop')
97
97
 
98
98
  const tape = new RecordTape<InputType, OutputType>({ path: tapeFilePath })
99
- tape.addLogItem('name', { input: [true], output: true, boundaries: {} })
100
- tape.addLogItem('name', { input: [true], error: 'invalid data', boundaries: {} })
99
+ tape.push({ input: true, output: true, boundaries: {}, type: 'success', taskName: 'name' })
100
+ tape.push({ input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name' })
101
101
 
102
102
  expect(() => tape.saveSync()).toThrow('Folder doesn\'t exists')
103
103
  })
104
104
 
105
105
  it('Save sync to a log file that doesnt exist', () => {
106
- type InputType = boolean[]
106
+ type InputType = boolean
107
107
  type OutputType = boolean
108
108
 
109
109
  const tapeFilePath = path.resolve(__dirname, './fixtures/nop')
@@ -116,8 +116,8 @@ describe('Save to file sync', () => {
116
116
  }
117
117
 
118
118
  const tape = new RecordTape<InputType, OutputType>({ path: tapeFilePath })
119
- tape.addLogItem('name', { input: [true], output: true, boundaries: {} })
120
- tape.addLogItem('name', { input: [true], error: 'invalid data', boundaries: {} })
119
+ tape.push({ input: true, output: true, boundaries: {}, type: 'success', taskName: 'name' })
120
+ tape.push({ input: true, error: 'invalid data', boundaries: {}, type: 'error', taskName: 'name' })
121
121
  tape.saveSync()
122
122
 
123
123
  const content = fs.readFileSync(tapeFilePath + '.log', 'utf8')